how to access a text file while debugging with eclipse CDT

前端 未结 5 1801
刺人心
刺人心 2020-12-21 04:16

I am writing this code to access a file in eclipse CDT

ifstream inFile;
ofstream outFile;
string next;

inFile.open(\"input.txt\");
if (inFile.fail())
{
             


        
5条回答
  •  暖寄归人
    2020-12-21 04:54

    It could be an issue with relative paths. Is input.txt in the root directory of your project? Eclipse makes the top-level directory of the project the working directory. If you replace "input.txt" in your code with the fully qualified file name, that should also work.

提交回复
热议问题