Question

Complete the C function to copy at most n characters from source starting at start_index into destination, ensuring destination is null-terminated. Assume destination has enough allocated memory. #include #include // For debugging, not strictly needed void safe_copy_substring(char* destination, const char* source, int start_index, int
n) {     int source_len = strlen(source);     if (start_index >= source_len) {         destination[0] = '\0'; // Source index out of bounds, return empty string         return;     }     int chars_to_copy = n;     if (start_index + chars_to_copy > source_len) {         chars_to_copy = source_len - start_index;     }     strncpy(destination, _________, chars_to_copy); // Line to complete     destination[chars_to_copy] = '\0'; // Ensure null-termination }

A source
B source + start_index
C &source[start_index]
D source[start_index]
E Both B and C are correct.
Practice Next

Hey! Ask a query