嗨,
我在 Qt Creator 和 Code :: blocks 上尝试了相同的代码,问题在于fscanf()
,它在 code :: blocks ,但在 Qt Creator 上,它不会更改其参数的值:S
main.cpp中:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
FILE * Dict = fopen("Dictionary.txt","r");
int nMots;
fscanf(Dict, "%d", &nMots);
cout << nMots;
fclose(Dict);
return 0;
}
Dictionary.txt:
7
whatever
...
输出代码:: blocks: 7
在Qt Creator上:一个随机整数,它与fscanf()
调用之前的值相同(nMots未初始化的结果)