Stripos

sahems87's Avatar, Join Date: Jun 2010
Newbie Member
stripos — Find position of first occurrence of a case-insensitive string
int stripos ( char* haystack, char* needle, int offset )
Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1.
The function should not make use of any C library function calls.
0
unni krishnan.r's Avatar, Join Date: Apr 2010
Skilled contributor
hmmm
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
How far have you got and where are you stuck? Do you understand the requirements?
How do you think it might work (i.e. outline the basic algorithm).
Do you know how to find a single char in a string? Since a string comprises multiple chars that might be a useful first step. Can you find an 's' in "haystack"? What about a 'u'? If you can find an 's', could you find "sta"? Could you find "sub"? For each question, why or why not?