This function or variable may be unsafe Consider using xxx instead

Source: Internet
Author: User

Problem:

The normal code running under Visual C ++ 6.0 cannot run in the Visual Studio 20xx series. Sometimes the following error is prompted:

Error C4996:'Fopen ':This function or variable may be unsafe. Consider usingFopen_sInstead. To disable deprecation, use _ CRT_SECURE_NO_WARNINGS. See online help for details.


Solution:

There are two solutions:

1,Follow the prompts to change fopen to fopen_s. (similar errors generally indicate that the xxx function is insecure. You can solve this problem by adding a suffix _ s ), however, you may find that... the parameter type does not match, so you need to change the parameter type. Is there any trouble! So there is a second method!

2,Take Visual Studio 2012 as an example. After opening the Project, select Project>Project nameProperties... -> Configuration Properties-> C/C ++-> Command Line add this sentence to the following Additional Options:/D "_ CRT_SECURE_NO_DEPRECATE" and click OK, re-compile the program without warning!





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.