pointers-memory · beginner · ~15 min

Find a character

Return a pointer into a string.

Challenge

Implement const char *find_char(const char *s, char c) returning a pointer to the first occurrence of c in s, or NULL if absent (like strchr).

Starter code

#include <stddef.h>

const char *find_char(const char *s, char c) {
    /* TODO */
    return NULL;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.