我的问题是 printf 没有给我任何输出。我完全糊涂了。知道为什么吗?
#include <stdio.h>
int main(){
char var[50];
scanf_s("%s", var); // visual studio force me to use scanf_s
printf("In: %s\n", var); // the output is just 'In:'
system("PAUSE");
return 0;
}
最佳答案
scanf_s
也需要大小作为参数;
scanf_s("%s", var, 50);
关于C scanf 字符数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20831187/