Borland C++ reference

tmpnam

raw OCR

Creates a unique file name.

Defined in header <stdio.h>

Syntax

#include <stdio.h>
char *tmpnam(char  *s);

Portability

DOSUNIXWindowsANSI CC++ only
■■■■

Remarks

tmpnam creates a unique file name, which can safely be used as the name of a temporary file, tmpnam generates a different string each time you call

it, up to TMP_MAXtimes. TMP_MAXis defined in stdio.h as 65,535.

The parameter to tmpnam, s, is either null or a pointer to an array of at

least LJmpnamcharacters. LJmpnamis defined in stdio.h. If s is null,

tmpnam leaves the generated temporary file name in an internal static object and returns a pointer to that object. If s is not null, tmpnam places its result in the pointed-to array, which must be at least LJmpnam characters long, and returns s.

tmpnam creates the temporary file in the directory defined by the TMP environment variable. If TMP is not defined, the TEMP environment variable is used. If neither TMP or TEMP is defined, tmpnam creates the files in the current directory.

If you do create such a temporary file with tmpnam, it is your responsi-bility to delete the file name (for example, with a call to remove). It is not deleted automatically, (tmpfile does delete the file name.)

Return value

If s is null, tmpnamreturns a pointer to an internal static object.
Otherwise, tmpnamreturns s.

See also

Example

#include <stdio.h>

int main (void)
{
char name [13];
tmpnam (name);
printf ("Temporary name: %s\n", name);
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.