0

I have a C++ program that reads some text files from a subdirectory located in the source code folder. The problem is that, the path that I've written in the program is relative and vs code outputs the debug program in /tmp/ directory, which is then unable to read those files. Is there some way of working around it except for giving the absolute path of text files to the program?

5
  • 1
    Configure the path where the debug program is created. This should be configurable in tasks.json and launch.json. Here is VSCode's page for configuring the debugger. Commented Sep 1, 2020 at 18:06
  • How will you find that file "in production"? Commented Sep 1, 2020 at 18:22
  • @Vlad Fernstein Why would I do debugging in production;)? Commented Sep 1, 2020 at 18:26
  • Change the CWD of your program when run from the IDE. Commented Sep 1, 2020 at 18:30
  • @ArpitBhadauria I am saying that you need a way to find your external file regardless of the "source code folder". Using that is not sensitive to the changes in the location of your executable Commented Sep 1, 2020 at 20:08

1 Answer 1

1

You need to configure the working directory for Debugging in the Configuration Properties, So that you can access the file required using relative path.

In project properties window Configuration Properties -> Debugging -> Working Directory update this to the desired path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.