pointers-memory · intermediate · ~15 min
Return a valid pointer only when the index is in range.
Implement const char *char_at(const char *s, int i) returning a pointer to character i of s if 0 <= i < length, else NULL — so callers never dereference out of range.
#include <string.h>
#include <stddef.h>
const char *char_at(const char *s, int i) {
/* TODO */
return NULL;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.