about strstr

str2 at start pos of str1;strstr return 0x0000 == NULL;
and if not fount str2 it also reture NULL;
this is may make mistake。

reference:
const char * strstr ( const char * str1, const char * str2 );
char * strstr ( char * str1, const char * str2 );
Locate substring

Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1.


str2 at start pos of str1;strstr return 0x0000 == NULL;


That's not correct. It will return a pointer to str1[0].

strstr returns a pointer to the memory location where the match was found, not an offset.

It only returns 0 if the string was not found.
Last edited on
ye,thats my fault!
how to close this topic
Last edited on
Topic archived. No new replies allowed.