1

Possible Duplicate:
fopen deprecated warning

While creating my project, I encountered this error:

error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h(218) : see declaration of 'fopen'

However, I have also included stdio.h and fstream as headers because others told me to do so. I still encounter the error.

Here is my code for the part of the error:

http://pastie.org/5796103

Can anyone help me?

Community
  • 1
  • 1
user1998492
  • 39
  • 1
  • 3
  • 8

1 Answers1

4

As the error states, you need to use fopen_s, or disable the security exception errors via adding #define _CRT_SECURE_NO_DEPRECATE before your include.

The reasoning behind these warnings, as well as how to disable them for various C Runtime functions, is described in detail in Security Enhancements in the CRT.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 6
    It's funny how often the answer is almost exactly the same as the error message, with the added hint to "read the error message". Maybe all error messages should be prefixed as "READ THIS MESSAGE". – paddy Jan 21 '13 at 22:37
  • 1
    @paddy Yeah - sometimes just rewording the language can help people understand, though. Using the macro in the error, however, will still cause a deprecation warning. – Reed Copsey Jan 21 '13 at 22:42