This C code snippet will attempt to find the first occurence of
needle in
haystack. For reference, the
strstr function returns a pointer to the first occurence of needle in haystack, or NULL if the needle is not found.
code:
#include <stdio.h>
#include <string.h>
main() {
char haystack[] = "This is our sentence";
char needle[] = "se";
if (strstr(haystack, needle)) printf("Found needle in haystack.");
else printf("Not found.");
}