1
I was studying with my friend, and we are breaking our heads because we do not know what exactly the NULL function is! Because in every program that we see, NULL can serve in another way, I’m going to put a program here as an example:
#include <stdio.h>
#include <string.h>
int main() {
char str1[21], str2[21];
printf("Digite duas palavras: ");
scanf(" %20[^\n] %20[^\n]", str1, str2);
if (strstr(str1, str2) != NULL) {
printf("%s ocorre em %s\n", str2, str1);
}
else {
printf("%s NAO ocorre em %s\n", str2, str1);
}
return 0;
}
If (strstr(str1,str2)) != NULL
? I didn’t understand that part, what do you mean?
The title of your question does not match your question in the last paragraph. The function
strstr
returns the pointer from where to find the substring in the larger string, and in the absence returnsNULL
– Jefferson Quesado