This chapter will examine a number of ways that a temporary file can be created under UNIX. Each of these has its advantages and disadvantages. The tmpnam(3) function is discouraged and is covered only because you will encounter it in existing code. The remaining functions can be used in new software.
The tmpnam(3) function generates a pathname for a new temporary file but does not create the temporary file itself. Its function synopsis is as follows:
#include <stdio.h> char *tmpnam(char *buf); /* Discouraged */
This function generates a temporary pathname in the directory given by the macro name P_tmpdir (defined in <stdio.h>). The argument buf must be null or point to a character buffer ...