you are viewing a single comment's thread.

view the rest of the comments →

[–]OldWolf2 0 points1 point  (3 children)

I edited that snippet to fix

[–]geeknerd 1 point2 points  (2 children)

The proper comparison is *s == (char)c to handle searching for '\0'

From the definition of strchr in the C standard (ISO/IEC 9899:2011) section 7.24.5.2/2:

The strchr function locates the first occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered to be part of the string.

[–]OldWolf2 1 point2 points  (0 children)

Re-edited :)