how to access a text file while debugging with eclipse CDT

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

    Other than moving your source input file, you may consider changing the working directory for launching the application.

    By setting "Run Configurations" > [The RUN] > "Arguments" Tab > "Working directory" from "${workspace_loc:[Project Name]}" to something else like "${workspace_loc:[Project Name]}/Release", which is the usual binary target directory for Eclipse would do.

提交回复
热议问题