Listing 5: tmpname.c
/*
* TMPNAME.C:
* Generates a temporary filename (in the /tmp directory).
* usage:
* tmpname [<prefix>]
* where <prefix> specifies the first few chars of the new name.
*/
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
{
int i, j;
char prefix[20];
prefix[0] = '\0';
if (argc == 2)
strcpy(prefix,argv[1]);
puts(tempnam("/tmp", prefix));
}
/* End of File */
|