From: http://apps.hi.baidu.com/share/detail/24671384
Problem: when programming in vs2005, the following problems are encountered:WarningC4996:"Fopen" is declared as rejected
Warning c4996: 'fopen': This function or variable may be unsafe
Explanation: Microsoft's warning mainly refers to functions in the C library. Many functions do not provide parameters internally.
Detection (including out-of-bounds), Microsoft worried that using this would cause memory exceptions, so it changed
The function with the same function is only used for parameter detection. You can use these new functions. No feature
Note: Every function will tell you the corresponding security function when giving a warning.
Yes, it will be used againCheck out msdn. Example of database function Rewriting:
Modify mkdir_ Mkdir
Fopen is rewrittenFopen_s
Rewrite stricmpStricmp_s
Solution: 1>Follow the following warning prompt: see the "fopen" statement.
Message: "ThisFunctionOrVariableMayBeUnsafe.ConsiderUsing
Fopen_sInstead.ToDisableDeprecation,Use_ Crt_secure_no_deprecate.
SeeOnlineHelpForDetails ."
Therefore, you can use the fopen_s function in the second sentence prompted by warning:
Eg: File* Pfile = fopen ("1.txt ","W ");
Changed:
File *Pfile;
Fopen_s (& pfile,"1.txt ","W ");
2>Follow the prompts in the following three sentences: Use_ Crt_secure_no_deprecate
Project | attribute | Configuration Attribute | C/C ++ | Command Line | add [/d
"_ Crt_secure_no_deprecate"] (Note: add the complete content in brackets)
3>Lower warning level: Project | attribute | Configuration Attribute | C/C ++ | standard, which lowers according to your situation
Warning Level (this method is not recommended)
Note: Warning is highly valued: the highest warning level of the compiler. Should require clean Construction
(No warning ). Understand all warnings. PassModify the code instead of lowering the warning level to exclude warnings.
.
The compiler is your friend. If it sends a warning to a constructor, it often indicates that
There are potential problems. Successful building should be silent (with no warning ).