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
Why calloc is better than malloc?
What are global variables and how do you declare them?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
What are variables c?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Why we use conio h in c?
What is the default value of local and global variables in c?
Can the sizeof operator be used to tell the size of an array passed to a function?
Explain the Difference between the New and Malloc keyword.
What is the use of getchar() function?
Explain do array subscripts always start with zero?
Explain the difference between malloc() and calloc() in c?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
How do you search data in a data file using random access method?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me