Definition | #include <stdio.h> char *mktemp(char *model);
For example, if the contents of model were "XXXX.ABC.XXXX" and the TSN of the running task were 6082, the temporary name generated by #T.A.ABC.6082 | |
Return val. | Pointer to the result string containing the new name | |
if successful. | ||
NULL pointer | if an error occurred, e.g. because model contains less than 8 characters or because the maximum permissible number (36) of | |
Notes | Since the letters A-Z and the digits 0-9 are used for the formation of a unique name, the number of Temporary files are automatically deleted on termination of a task (LOGOFF). However, the files are retained if the standard prefix (#) for temporary files was changed during system generation. | |
Example | The following program generates three unique temporary file names and opens the files for writing and reading. #include <stdio.h> FILE *fp1, *fp2, *fp3; char s[] = "XXXX.temp.XXXX"; int main(void) { mktemp(s); fp1 = fopen(s,"w+r"); printf("%s\n",s); /* generated name: #T.A.TEMP.6082 */ mktemp(s); fp2 = fopen (s,"w+r"); printf("%s\n",s); /* generated name: #T.B.TEMP.6082 */ mktemp(s); fp3 = fopen (s,"w+r"); printf("%s\n",s); /* generated name: #T.C.TEMP.6082 */ return 0; } | |