basics · beginner · ~15 min

Implement my_strlen

Walk a C string to its NUL terminator.

Challenge

Implement size_t my_strlen(const char *s) returning the number of characters before the terminating NUL — without calling strlen.

Starter code

#include <stddef.h>

size_t my_strlen(const char *s) {
    /* TODO */
    return 0;
}

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