C:tmpnam
Example
The following example shows the usage of tmpnam()
function.
#include <stdio.h>
int main()
{
char buffer[L_tmpnam];
char *ptr;
tmpnam(buffer);
printf("Temporary name 1: %s\n", buffer);
ptr = tmpnam(NULL);
printf("Temporary name 2: %s\n", ptr);
return(0);
}
Let us compile and run the above program to produce the following result:
tmpnam is dangerous
tmpnam()
는 보안상 위험한 함수이다. (함수이름이 반환되는 순간 다른 프로세스에서 핸들을 가로챌 수 있다) POSIX에서는 mkstemp를 사용하는 것을 추천한다.