tmpnam()

Declaration

char* tmpnam(char* cpString);

Description:

This function creates a name (of a file that does not exist in the current directory) in the string "cpString" that can be used to create temporary files. The function returns a pointer to the string containing the filename, if the call was successful and NULL otherwise.

Example

#include <cstdio>

int main()
{
    // Get unique file name, using NULL for the argument
    char* cpTempName = tmpnam(0);

    if (cpTempName) {
        printf("Use %s as a temp file name.\n", cpTempName);
    } else {
        printf("No temp file name was found.\n");
        return 1;
    }

    return 0;
}

Output:

signal() Output