linux-sysprog · beginner · ~15 min

Reentrant function variant

Recognise reentrant (_r) library variants.

Challenge

Implement int is_reentrant(const char *fn) returning 1 for the thread-safe _r variants "strtok_r" and "localtime_r", and 0 for "strtok" and "localtime".

Starter code

#include <string.h>

int is_reentrant(const char *fn) {
    /* TODO */
    return 0;
}

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