Is there something like startsWith(str_a, str_b) in the standard C library?
startsWith(str_a, str_b)
It should take pointers to two strings that end with nullbytes, and tell me
I'm no expert at writing elegant code, but...
int prefix(const char *pre, const char *str) { char cp; char cs; if (!*pre) return 1; while ((cp = *pre++) && (cs = *str++)) { if (cp != cs) return 0; } if (!cs) return 0; return 1; }