Let*_*rus 4 c c++ eclipse linux eclipse-cdt
我正在编写此代码来访问eclipse CDT中的文件
ifstream inFile;
ofstream outFile;
string next;
inFile.open("input.txt");
if (inFile.fail())
{
cout << "\nCould not open input.txt";
exit(1);
}
Run Code Online (Sandbox Code Playgroud)
问题是当我尝试调试我的应用程序或从eclipse中运行我的应用程序时,它无法找到input.txt文件.当我从控制台运行我的应用程序时它工作正常并打开文件.我需要调试应用程序,但不能,因为由于某种原因,eclipse ide无法找到该文件.
我应该把文件放在哪里?
这可能是相对路径的问题.是input.txt在你的项目的根目录?Eclipse使项目的顶级目录成为工作目录.如果"input.txt"用完全限定的文件名替换代码,那也应该有效.