-1

I'm learning C in VS Code and I want to find a way, if there is one, to create multiple source files in one folder to test my coding examples. Otherwise, I need to create a separate folder for each coding example and it's a bit annoying. Is there a way to do this by changing the configuration of the '.json' files? Thanks.

1
  • 1
    correct me if wrong; but your requirement is : a single folder, with single task configuration and all your .c files in it? Commented Sep 19, 2020 at 9:15

1 Answer 1

1

You can achieve what you want by having a task.json some thing as below:

{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "C/C++: g++-10 build active file", "command": "/usr/local/bin/g++-10", "args": [ "-g", "${file}", "-o", "${fileDirname}/build/${fileBasenameNoExtension}" ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": [ "$gcc" ], "group": "build" } ] } 

This above task will build the .c file which is currently active in your vscode. Also, it will put your executable file in a single build folder. So you can have all your c/CPP files in a single source folder and all your executables will be lying in the build folder.

P.S: make sure to change the command according to whatever compiler you are using.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.