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 About fork()?
Explain can static variables be declared in a header file?
What does printf does?
How can I change the size of the dynamically allocated array?
What is indirection in c?
What is a buffer in c?
What are valid signatures for the Main function?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
Who developed c language?
What does static variable mean in c?
how should functions be apportioned among source files?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
What is a wrapper function in c?
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers