This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

tmpnam

Prototype

#include <stdio.h>

char *tmpnam(char *s);

Description

Generates an unique file name useful to be used for creating temporary files. It generates a different name each time it is called, up to TMP_MAX times (if it is called more that TMP_MAX times, the behaviour is implementation-defined). If the argument s is not NULL, the s buffer (assumed to have a size of at least L_tmpnam characters) is used for storing the generated file name, then the s value is returned. If the argument s is NULL, an internal static buffer is used for storing the generated file name, and a pointer is returned to that buffer. Please note that in the latter case subsequent calls to tmpnam may modify the same internal buffer.

Example

View source
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char *name;

    name = tmpnam(NULL);
    printf("Generated temporary name is \"%s\"\n", name);

    return EXIT_SUCCESS;
}

References

ISO C 9899:1990 7.9.4.4