STRSTR()
this function filters for a specific pattern (a word or substring) within a larger string. it can be used in content filtering by finding a specific word in a given message or file.
#include <stdio.h>
#include <string.h>
int main() {
// Declare and initialize a message
char message[] = "This is an important notice for all employees.";
// Use strstr to find the substring "Important"
char *result = strstr(message, "Important");
// Check if the substring "Important" is found
if (result != NULL) {
printf("The message is important!\n");
} else {
printf("The message is not important!\n");
}
return 0;
}
Last updated