Pointer to a constant `struct tm`, which represents broken-down time values including year, month, day, hour, minute, and second.
1st Parameter
Pointer to a `struct tm` representing broken-down time
2nd Parameter Type : char *
String pointer (array of characters)
2nd Parameter
Pointer to a user-supplied buffer to store the resulting string
Read more about parameters of asctime_r in parameters section
The asctime_rfunction in C language Thread-safe version of asctime.
The asctime_r function is a thread-safe version of asctime. It converts a time structure (struct tm) to a string representation and stores the result in a user-provided buffer. This function is reentrant and can be used safely in multi-threaded programs. The resulting string has the form 'Day Mon dd hh:mm:ss yyyy\n'.
The asctime_rfunction takes 2
parameters:
•
const struct tm * `timeptr`: Pointer to a `struct tm` representing broken-down time
•
char * `buffer`: Pointer to a user-supplied buffer to store the resulting string
The asctime_r function return value :
Returns a pointer to the string result if successful, or NULL if an error occurred
Output
This example demonstrates the basic usage of the `asctime_r` function to convert the current local time to a string representation in a thread-safe manner.