I saw this question but none of the answers were quite what I was looking for. I've tried strstr but it returns a pointer instead of an integer index.
I need to find if string a contains string b and if so, where it's located, kind of like the index returned by strcmp. Is there a function or easy way to do this in C?
For example, if a is "foobar" and b is "bar", then this function/method would return 3 because "bar" is at index 3 of "foobar".
Any help is appreciated!
strstrdoes just that - if it doesn't work as you expect it to, you should post your code here and explain the problem you have with the behavior ofstrstrin it."bar"is at index3in"foobar", not2.