Return a unique name for temporary file creation.




This function does not have any input parameters.


The tmpnam() function returns a name that is guaranteed to be unique and can be used to pass to the fopen function for creating temporary files. 

The semantics of the tmpnam() function are similar to that of the C tmpnam() routine--notably, a restricted number of unique names are returned by the tmpnam() routine as defined by the C constant TMP_MAX. All PSL processes on a given PATROL Agent share the same set of names, and there can be a danger of mixing names. ANSI C guarantees that TMP_MAX is at least 25, but it is typically much larger than that. If the size of TMP_MAX is a concern, add a suffix to the returned file name.


The following example shows how to use the tmpnam() function to generate a temporary file name. The PSL function adds a suffix to the returned name to further guarantee its uniqueness.

name = tmpnam() . ".dave";
printf("The generated name is: %s \n",name);
fp = fopen(name, "w");

Was this page helpful? Yes No Submitting... Thank you