C – mkstemp 로 생성된 파일명 알기

By | 2024년 1월 31일
Table of Contents

C – mkstemp 로 생성된 파일명 알기

파라미터로 전달된 템플릿 자체를 수정해서 파일명으로 변경한다.
따라서, 전달된 템플릿은 readonly 가 될 수 없고, 반복적으로 사용하기 위해서는 템플릿을 새로운 char 배열에 복사해서 mkstemp() 에 전달해야 한다.

/* Generate a unique temporary file name from TEMPLATE.
   The last six characters of TEMPLATE must be "XXXXXX";
   they are replaced with a string that makes the filename unique.
   Returns a file descriptor open on the file for reading and writing,
   or -1 if it cannot create a uniquely-named file.

   This function is a possible cancellation point and therefore not
   marked with __THROW.  */

답글 남기기