warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To

warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.为什么是不安全的?

第1个回答  2010-02-03
这是新版vc库添加的警告

因为微软认为scanf的使用存在安全隐患,因为C/C++中的字符串处理都是以\0为截止符的,如果搜索不到\0,容易出现字符串越界

所有vc扩展的所谓安全标准库,都添加了一个参数用以指定字符串参数的长度,用以避免这种安全隐患。本回答被提问者采纳
相似回答