我正在使用 fscanf
从文件中读取一些 int
值。它工作正常,但按照我的方式,编译器给出了一些警告。
来源:
FILE *fp = NULL;
fp = fopen(argv[1],"r");
int num;
while(fscanf(fp,"%d",&num) != EOF) // This is the line 46
printf("%d ",num);
警告:
passing argument 1 of ‘fscanf’ from incompatible pointer type
format not a string literal and no format arguments [-Wformat-security]
passing argument 2 of ‘fscanf’ from incompatible pointer type
Line breakpoint: main.c [line: 46]
我做错了什么?
最佳答案
重新定义fscanf的原型(prototype),实际代码不同例如fscanf("%d",&num)
。 (保存之前?) – BLUEPIXY
关于c - 如何修复使用 fscanf() 时出现的警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30855973/