...
Code Block |
---|
... int fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY, new_file_mode); if (fd == -1) { /* Handle Error */ } ... |
Compliant Solution 2
Wiki Markup |
---|
The function {{fdopen()}} \[[Open Group 04|AA. C References#Open Group 05]\] can be used to associate a stream with a file descriptor. |
Code Block |
---|
... FILE *fp; int fd; fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY, new_file_mode); if (fd == -1) { /* Handle Error */ } fp = fdopen(fd,"w"); if (fp == NULL) { /* Handle Error */ } ... |
...