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 are the valid places to have keyword “break”?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
how is the examination pattern?
Why & is used in scanf in c?
Explain what is the general form of a c program?
How many levels deep can include files be nested?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
diff between exptected result and requirement?
What is time null in c?
can we implement multi-threads in c.
When can you use a pointer with a function?
How do I read the arrow keys? What about function keys?
write a program to create a sparse matrix using dynamic memory allocation.
Explain what is dynamic data structure?
Write a program to print "hello world" without using a semicolon?