gtpc2m7m | C/C++ Language Support User's Guide |
This function produces a temporary name.
Format
#include <stdio.h> char *tmpnam(char *string);
This function produces a valid file name that is not the same as the name of any existing file. It stores this name in string. If string is a NULL pointer, the tmpnam function leaves the result in an internal static buffer. Any subsequent calls may modify this object. If string is not a NULL pointer, it must point to an array of at least L_tmpnam bytes. The value of L_tmpnam is defined in the stdio.h header file.
Normal Return
If string is a NULL pointer, the tmpnam function returns the pointer to the internal static object in which the generated unique name is placed. Otherwise, if string is not a NULL pointer, it returns the value of string. The tmpnam function produces a different name each time it is called in a module up to at least TMP_MAX names. Files created using names returned by tmpnam are not automatically discarded at the end of the program.
Error Return
Not applicable.
Programming Considerations
The TPF system does not support creating, updating, or deleting files in 1052 or UTIL state. Special files may or may not be writable in 1052 or UTIL state depending on the device driver implementation.
Examples
The following example calls the tmpnam function to produce a valid file name.
#include <stdio.h> int main(void) { char *name1; if ((name1 = tmpnam(NULL)) !=NULL) printf("%s can be used as a file name.\n", name1); else printf("Cannot create a unique file name\n"); }
Related Information
See Appendix E, Programming Support for the TPF File System for more information about TPF File System C Functions.