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 kanawally
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;
}
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
what is bit rate & baud rate? plz give wave forms
What kind of structure is a house?
What is the total generic pointer type?
Why do we use pointer to pointer in c?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
how should functions be apportioned among source files?
Explain how do you declare an array that will hold more than 64kb of data?
What is the purpose of sprintf?
a c code by using memory allocation for add ,multiply of sprase matrixes
Write a program with dynamically allocation of variable.
What is the explanation for prototype function in c?
What is the translation phases used in c language?
How can you avoid including a header more than once?
Explain what is #line used for?
What are types of functions?