Write the following function in C.
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.
Answer Posted / anand
int stripos ( char* haystack, char* needle, int offset )
{
char *ptr;
ptr=haystack;
int pos=0;
while ( *ptr!='\0' )
{
if( *ptr == *needle )
return pos;
pos++;
ptr++;
}
return -1;
}
this function written for exact match of the charecter and
dosent bother for whatever is offset.
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
Differentiate between new and malloc(), delete and free() ?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
Tell us the use of fflush() function in c language?
Define VARIABLE?
Can you please explain the scope of static variables?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
Does c have an equivalent to pascals with statement?
what is the significance of static storage class specifier?
how could explain about job profile
What is typedef example?
Explain what is a const pointer?
How does placing some code lines between the comment symbol help in debugging the code?