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 / varun vithalani
I am working on the answer now but i can say that answer 1
and 2 are absolutely wrong. I haven't checked the 3rd yet.
In 1 and 2 solutions, it only looks for the first character
of the needle and does not care about the remaining.
For example:
haystack = "sweetsugar"
needle = "sugar"
It will return value '0' since it matches the first 's' of
'sweetsugar' and 'sugar'. The answer should be '5'.
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Under what circumstances does a name clash occur?
Explain what is the benefit of using #define to declare a constant?
What does typeof return in c?
Explain indirection?
What is difference between constant pointer and constant variable?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
What are the types of type specifiers?
What is strcpy() function?
What is the size of structure in c?
What do header files do?
Write a code to generate a series where the next element is the sum of last k terms.
How can I generate floating-point random numbers?
What are near, far and huge pointers?
How to compare array with pointer in c?
What are the basic data types associated with c?