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
Explain how do you override a defined macro?
What are the advantages of c language?
What is null pointer constant?
What is else if ladder?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What is the use of function overloading in C?
What is the use of gets and puts?
Do you know the difference between exit() and _exit() function in c?
What is #define used for in c?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
How was c created?
What are linker error?
What is the scope of an external variable in c?
What is the advantage of using #define to declare a constant?
What does dm mean sexually?