Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: put code in monospace font and added () to end of function names

...

Code Block
bgColor#ccccff
langc
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)

...