FILE *datapad;
char filename[20];
printf("please enter file \n");
scanf(" %s", &filename);
fflush(stdin);
printf("processing");
datapad = fopen(filename,"r");
所以上面是我正在开发的一个项目的代码,但是当我编译代码并运行它时,它卡在了 scan f 命令处,我无法弄清楚出了什么问题,我已经尝试过 fflush命令,我使用 & 符号进行了正确的格式化。
最佳答案
scanf()
的格式不正确
main()
{
char filename[20];
printf("please enter file \n");
scanf("%19s", filename);
printf("processing %s...\n", filename);
}
输出:
please enter file
/we/sd/xc
processing /we/sd/xc...
关于c - c 中的 scanf 命令出现问题(在论坛中找不到其他地方),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48757808/