...
Wiki Markup |
---|
The function {{fdopen()}} \[[Open Group 04|AA. C References#Open Group 05]\] can be used in conjunction to {{open()}} to to determine if an existing file has been opened, or a new file has been created and then 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 */ } ... |
...