程序清单4.1用VS2019为什么错误

#include<stdio.h>
#include<string.h>
#define DENSITY 62.4
int main()
{
float weight,volume;
int size,letters;
char name[40];//不初始化会报错

printf("Hi! What's your first name?\n");
scanf("%s",name);/* scanf不改成scanf_s会报错*/
printf("%s, what's your weight in pounds?\n",name);
scanf_s("%f",&weight);//这里直接跳过这个输入了,为什么?
}
C Primer Plus,第四章,开头的程序清单4.1,为什么在vs2019上是错误的

VS2019对数据初始化和字符串的安全性等都更加严格,以前可以只是警告。
严格的目的是养成良好的编码习惯,否则系统容易出现各种问题。
scanf_s就是scanf的安全版本,避免字符串长度不够造成溢出

scanf_s("%s", name,40);/* scanf不改成scanf_s会报错*/