C string startswith

Posted on 2014-10-02 00:00:00 +0800

Just a nice snippet of code I found useful;

It gets the position of the needle in the haystack using

1
strstr
(who came up with that name, seriously), then, as
1
strstr
returns a pointer to the needle’s occurance in the string, we simply make sure that if it ain’t null, and that it’s equal to the original string.

Day to day C stuff, I guess.