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 Answer
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.