我正在尝试调试我的程序,并且正在从名为 intInputFile 的文件中读取值。我正在查看我的局部变量,发现它说 intInputFile = 不完整类型。我已经尝试查找它,但没有明确的答案,我不知道这是什么意思。谁能解释一下,因为我认为这弄乱了我的程序。
谢谢。
intInputFile >> fileInt;
cout << "check" <<endl;
while(!intInputFile.eof())
{
intNode* anotherInt;
anotherInt = new intNode;
if(intList==NULL)
{
intList = anotherInt;
lastInt = anotherInt;
lastInt->nextNode = NULL;
lastInt->nextNode = new intNode;
}
else
{
lastInt = lastInt->nextNode;
lastInt->nextNode = NULL;
lastInt->nextNode = new intNode;
}
lastInt->intValue = fileInt;
intInputFile >> fileInt;
cout << "good" <<endl;
}
第一次执行后,它正确地从文件中读取了第一个整数,但我在调试时注意到了不完整的类型。另外,我包括 cout <<"good"; 看看它是否会运行到那个点,当我的程序执行时,它所做的只是反复显示“好”。
以下是包括:
#include <iostream>
#include <string>
#include <fstream>
我将其定义为常规 ifstream 类型:
int fileInt; //int read from input file
ifstream intInputFile;