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!