...
Code Block | ||||
---|---|---|---|---|
| ||||
char *file_name; FILE *fp; /* Initialize file_name */ errno_t res = fopen_s(&fp, file_name, "wx"); if (res != 0) { /* Handle error */ } |
On Windows, fopen_s()
will create the file with security permissions based on the user executing the application. For more controlled permission schemes, consider using the CreateFile()
function, and specifying the SECURITY_ATTRIBUTES
parameter.
Noncompliant Code Example (open()
, POSIX)
...