C/File/File Temp
Create temp file name
#include <stdio.h>
int main(void)
{
char name[40];
int i;
for(i=0; i<3; i++) {
tmpnam(name);
printf("%s ", name);
}
return 0;
}
Generate a unique temporary filename: tmpnam
#include <stdio.h>
int main ()
{
char buffer[L_tmpnam];
char *pointer;
tmpnam (buffer);
printf ("Temp file name #1: %s\n",buffer);
pointer = tmpnam (NULL);
printf ("Temp file name #2: %s\n",pointer);
return 0;
}
Open a temporary file: how to use tmpfile
#include <stdio.h>
int main ()
{
FILE *file;
file = tmpfile();
// file is pointing to a temp file.
fclose (file);
return 0;
}