basics · beginner · ~15 min

Reverse a string

Combine the two-pointer pattern with C strings.

Challenge

Implement void reverse(char *s) that reverses the null-terminated string s in place.

Starter code

#include <string.h>

void reverse(char *s) {
    /* TODO */
}

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