VS2013运行报错error C4996: 'scanf': This function or variable may be unsafe.

报错内容:

1>------ Build started: Project: 约瑟夫问题, Configuration: Debug Win32 ------
1>  约瑟夫问题.cpp
1>c:\users\xuchunyan\documents\visual studio 2013\projects\约瑟夫问题.cpp(11): error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          d:\program files\visual studio\vc\include\stdio.h(283) : see declaration of 'scanf'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

解决方法

在文件第一行(注意一定是第一行)加上一句:

#define _CRT_SECURE_NO_DEPRECATE

你可能感兴趣的:(Bugs)