basics · beginner · ~15 min
Index into a char array and handle the empty case.
Implement char first_char(const char *s) returning the first character, or '\0' if the string is empty.
char first_char(const char *s) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.