basics · intermediate · ~15 min
Compare a bounded number of leading characters.
Implement int has_prefix(const char *s, const char *pre) returning 1 if s begins with pre, else 0.
int has_prefix(const char *s, const char *pre) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.