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


Please Help Members By Posting Answers For Below Questions

Explain what is wrong with this program statement? Void = 10;

768


What is difference between structure and union?

606


The statement, int(*x[]) () what does in indicate?

653


Explain what are global variables and explain how do you declare them?

645


What is the difference between printf and scanf )?

603






Differentiate between the = symbol and == symbol?

723


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2381


Is main is a keyword in c?

616


What is "Duff's Device"?

706


What is pointer and structure in c?

577


What is the difference between printf and scanf in c?

757


How can I ensure that integer arithmetic doesnt overflow?

614


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1259


why return type of main is not necessary in linux

1710


how to create duplicate link list using C???

2081