 
                            ...
| Wiki Markup | 
|---|
| This solution is also non-compliant because it violates \[[FIO32-C|FIO32-C. Temporary file names must be unique when the file is created]\] and \[[FI042-C|FI042-C. Temporary files must be removed before the program exits]\]. | 
Non-Compliant Code Example: mktemp()/open() (POSIX)
The POSIX function mktemp() takes a given file name template and overwrites a portion of it to create a file name. The template may be any file name with some number of 'X's appended to it, for example /tmp/temp.XXXXXX. The trailing 'X's are replaced with the current process number and/or a unique letter combination. The number of unique file names mktemp() can return depends on the number of 'X's provided.
| Code Block | ||
|---|---|---|
| 
 | ||
| ... FILE *temp_ptrint fd; char temp_name[] = "/tmp/temp-XXXXXX"; if (mktemp(temp_name) == NULL) { /* Handle Error */ } temp_ptrif ((fd = fopenopen(temp_name,"w+"); if (temp_ptr O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, 0600)) == NULL-1) { /* Handle Error */ } ... | 
...