...
Code Block | ||||
---|---|---|---|---|
| ||||
char *file_name; FILE *fp; /* initializeInitialize file_name */ fp = fopen(file_name, "w"); if (!fp) { /* Handle error */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
char *file_name; FILE *fp; /* initializeInitialize file_name */ errno_t res = fopen_s(&fp, file_name, "w"); if (res != 0) { /* Handle error */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
char *file_name; /* initializeInitialize file_name */ FILE *fp = fopen(file_name, "wx"); if (!fp) { /* Handle error */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
char *file_name; int new_file_mode; /* initializeInitialize file_name and new_file_mode */ int fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY, new_file_mode); if (fd == -1) { /* Handle error */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
char *file_name; int new_file_mode; FILE *fp; int fd; /* initializeInitialize file_name and new_file_mode */ 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 */ } |
...
[Callaghan 1995] | IETF RFC 1813 NFS Version 3 Protocol Specification |
[ISO/IEC 9899:2011] | Section 7.21.5.3, "The fopen Function" |
[Loosemore 2007] | Section 12.3, "Opening Streams" |
[Open Group 2004] | |
[Seacord 2005a2013] | Chapter 78, "File I/O" |