how to access a text file while debugging with eclipse CDT

前端 未结 5 1806
刺人心
刺人心 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:55

    I found that with Eclipse, having the file in the root directory of the project should let it load. However, if you want to run it from the command line, the file needs to be in the same folder as the executable (something like Debug/ inside the project folder).

    It should work to drag and drop the file into your Eclipse project. Just make sure that you select the option to Copy the file, rather than Link to it.

提交回复
热议问题