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.



stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* ha..

Answer / Sampurnanand Tripathi

This is a function in C that returns the numeric position of the first occurrence of the 'needle' string within the 'haystack' string, ignoring case sensitivity. If 'needle' is not found, it will return -1. Here's an example implementation:

```c
#include <stdio.h>
#include <string.h>

int stripos(char *haystack, char *needle) {
int len_needle = strlen(needle);
int i;

for (i = 0; haystack[i] != ''; ++i) {
if (strncasecmp(&haystack[i], needle, len_needle) == 0) {
return i;
}
}

return -1;
}
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Are the variables argc and argv are local to main?

1 Answers   TISL,


Function to find the given number is a power of 2 or not?

20 Answers   Motorola, nvidia,


Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4 1) Quick Sort 2) Bubble Sort 3) Merge Sort

7 Answers  


How can I split up a string into whitespace-separated fields?

1 Answers  


What is the difference b/w main() in C language and main() in C++.

7 Answers  


What is the purpose of clrscr () printf () and getch ()?

1 Answers  


Why array starts with index 0

2 Answers  


Explain the difference between malloc() and calloc() function?

1 Answers  


Why is c used in embedded systems?

1 Answers  


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

1 Answers  


when i declare as: void main() { clrscr(); int a=10; printf("%d",a) } my problem that why generate a error in above programs. please tell me answer seriously .

4 Answers  


Differentiate between new and malloc(), delete and free() ?

1 Answers   iNautix,


Categories