 
                            ...
| Code Block | ||
|---|---|---|
| 
 | ||
| 
char sfn[] = "/tmp/temp-XXXXXX";
FILE *sfp;
int fd = -1;
if (fd = mkstemp(sfn)) == -1) {
  /* Handle Error */
}
 
if (sfp = fdopen(fd, "w+")) == NULL) {
 unlink(sfn);
 close(fd);
} else {
  unlink(sfn); /* unlink immediately to allow name to be recycled*/
  /* use temporary file */
  fclose(sfp); /* also closes fd */
} 
 | 
| Wiki Markup | 
|---|
| The Open Group Base Specification Issue 6 \[[Open Group 04|AA. C References#Open Group 04]\] does not specify the permissions the file is created with, so these are [implementation-defined|BB. Definitions#implementation-defined behavior]. However, Issue 7 (that is, POSIX.1-2008) specifies them as {{S_IRUSR\|S_IWUSR}} (0600). | 
...