Question

A C function attempts to find a substring. #include #include char* find_substring(char* haystack, char* needle) {     if (haystack == NULL || needle == NUL

  • L {         return NULL;     }     return strstr(haystack, needle); } int main() {     char* text = "Hello World";     char* pattern = NULL; // Potential bug here     char* result = find_substring(text, pattern);     if (result != NUL
  • L {         printf("Found: %s ", result);     } else {         printf("Not found or invalid input. ");     }     return 0; } What will be the output of this C program?
A Found: World
B Not found or invalid input.
C A segmentation fault (crash).
D Found: (null)
E A compile-time error.
Practice Next

Hey! Ask a query