Pointer to a user-provided array of at least `L_tmpnam` characters where the function can store the generated file name. If `str` is `NULL`, the function uses an internal static buffer.
Read more about parameters of tmpnam in parameters section
The tmpnamfunction in C language Generates a unique temporary filename.
The tmpnam function generates a string that is a valid filename and that is not the same as the name of an existing file. This function is potentially dangerous because it creates a window of opportunity between the generation of the name and the creation of the file. For a safer alternative, consider using tmpfile().
The tmpnamfunction takes 1
parameter:
•
char * `str`: Pointer to a user-provided array of at least `L_tmpnam` characters where the function can store the generated file name. If `str` is `NULL`, the function uses an internal static buffer.
Generates a unique temporary file name. If `str` is not `NULL`, the file name is stored in the provided buffer. If `str` is `NULL`, the function uses and returns a pointer to an internal static buffer. Returns a pointer to the generated file name or `NULL` if an error occurs. The generated name is not guaranteed to correspond to an existing file, and it is the user's responsibility to create the file if needed.
The tmpnam function return value :
If the argument is NULL, returns a pointer to an internal static array
If the argument is not NULL, returns the argument
Output
This example generates a temporary filename and stores it in a buffer.