Mega Code Archive

 
Categories / C / Code Snippets
 

Generates a unique filename

//Declaration: char *tmpnam(char *name); //Parameters: *name should be at least L_tmpnam characters long. L_tmpnam is defined in <stdio.h>. //Return: the unique temp name on success or a null pointer on error. #include <stdio.h> int main(void) { char name[60]; int j; for(j=0; j<3; j++) { tmpnam(name); printf("%s ", name); } return 0; }