C Language: tmpnam function(Generate Temporary File Name)

In the C Programming Language, the tmpnam function creates a name for a temporary file. If the argument is a null pointer, the tmpnam function will store the file name in a static variable and return a pointer to it. Otherwise, the tmpnam function will copy the file name into s.


The syntax for the tmpnam function in the C Language is:

char *tmpnam(char *s);

Parameters or Arguments


The character array to copy the file name.


The tmpnam function returns a pointer to the file name.

Required Header

In the C Language, the required header for the tmpnam function is:

#include <stdio.h>

Applies To

In the C Language, the tmpnam function can be used in the following versions:

  • ANSI/ISO 9899-1990

stdio.h Functions