strstr() function like, that ignores upper or lower case
I have two strings. Lets say `
str1="One Two Three";
I would like to know if there is any function that checks for a match of the second string in the first one,and returns me a pointer to the first occurrence, something like
strstr(), but which doesn't treat the same letter, upper or lowercase, as two different characters.
For my example, the function should find a match for
str2 in the first string, despite the uppercase
From the manpage for
STRSTR(3) Linux Programmer's Manual STRSTR(3) NAME strstr, strcasestr - locate a substring SYNOPSIS #include char *strstr(const char *haystack, const char *needle); #define _GNU_SOURCE #include char *strcasestr(const char *haystack, const char *needle); DESCRIPTION The strstr() function finds the first occurrence of the substring needle in the string haystack. The terminating '\0' characters are not compared. The strcasestr() function is like strstr(3), but ignores the case of both arguments. RETURN VALUE These functions return a pointer to the beginning of the substring, or NULL if the substring is not found.
So what you're looking for is