Next: , Previous: , Up: ISO C and POSIX Function Substitutes   [Contents][Index]

9.179 ctime_r

POSIX specification:

Gnulib module: extensions

Portability problems fixed by Gnulib:

Portability problems not fixed by Gnulib:

ctime_r takes a pre-allocated buffer and length of the buffer, and returns NULL on errors. The input buffer should be at least 26 bytes in size. The output string is locale-independent. However, years can have more than 4 digits if time_t is sufficiently wide, so the length of the required output buffer is not easy to determine. Increasing the buffer size when ctime_r returns NULL is not necessarily sufficient. The NULL return value could mean some other error condition, which will not go away by increasing the buffer size.

A more flexible function is strftime. However, note that it is locale dependent.