VS2015 scanf 函数报错 error C4996: ‘scanf’

  • Post author:
  • Post category:其他



错误提示:


error C4996: ‘scanf’: This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use



_CRT_SECURE_NO_WARNINGS



. See onlin


e help for details.


具体如下,这是一个计算输入字符串长度的程序:

#include "stdio.h"

int main() {
	char s[30];
	char* p;
	scanf("%s", s);
	p = s;
	while (*p != '\0'){ p++; }
	printf("%d\n", p - s);
	while (1);
	return 0;

编译结果:

1>------ Build started: Project: Learnc, Configu



版权声明:本文为jh0703原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。