title: Using fopen_s in C
body: <p>I have a problem with programming in C, especially with fopen in Visual Studio. I read about the <code>fopen_s</code> function and added the following line to my project, but it still doesn't work.</p>
  
  <pre><code>_CRT_SECURE_NO_WARNINGS
  </code></pre>
  
  <p>So I tried using <code>fopen_s</code> in this way:</p>
  
  <pre><code>FILE *fp;
  errno_t err;
  if ((err = fopen_s(&amp;fp, "C:/File.txt", "rt")) != 0)
      printf("File was not opened\n");
  else
      fprintf(fp, "Date: %s, Time: %s, Score: %i \n", __DATE__, __TIME__, score);
  fclose(fp);
  </code></pre>
  
  <p>It's still crashing. What's wrong?</p>