2
这是我的代码。在C++中,打开带有值的.txt文件后,读取文件给我“”
ifstream readFile;
readFile.open("voltages.txt");
if (readFile.fail())
{
cout << "\nCould not open the file ... check to see if voltages.txt exists\n";
system("pause");
return;
}
string tempString = "";
//readFile.seekg(0, ios::beg);
int idx = 0;
if (readFile.is_open())
{
while (readFile.good())
{
getline(readFile,tempString);
cout << tempString << endl;
}
readFile.close();
}
如果我移动voltages.txt到c:/,那么它工作正常,但我有它在同一文件夹中的.exe我现在,当我设置一个断点在COUT < < tempString endl; < < endl;它显示为“”。如果可能,我想保留在.exe中。正如你所看到的,我试图寻求开始,没有运气。请帮助这个C++ noob!谢谢!
多少行的时候voltages.txt是不是在C它读:/? –
它只读一行,即“” – KKendall