1、输入并不匹配函数 int fscanf(FILE *fp, char
*format, ...) 或 int scanf(const char *format, ...) 中format所指定的输入格式。
2、输入数据超过而溢出而覆盖其他内存区域。
二、下面详细介绍一下出现上面两种问题的原因,及相应的解决方法。
情况1:输入格式不匹配:
如:
int i;
scanf("%d",&i);
输入内容:c
上述scanf函数执行的结果并没有从标准输入中读取数据放在i所在内存地址。根据K&R C 对scanf描述:"
It returns when format is exhausted. fscanf returns EOF if end of file or an error occurs before any conversion; otherwise it returns the number of input items converted and assigned."