对字符和字符串,scanf_s需要增加一个表示缓冲区长度的参数,改成这样:scanf_s("%c", &keyval,1);
#includeint main(){ char keyval; printf("请输入一个字符:"); scanf("%c", &keyval); printf("The keyval is %c\n", keyval); return 0;}