The below code is the configuration for the Microsoft Visual Code tasks which will enable you to compile and run C program
- Press
Cmd + Shift + P
- Type
Configure task
( A task.json file will be created for that project ) - Copy below configuration code and save it.
Simple press Cmd + Shift + B
to compile and run.
Note: Make sure you select the tab having C program as below tasks run on active tab in VS Code.
{
"version": "2.0.0",
"tasks": [
{
"label": "compile and run C",
"type": "shell",
"command": "gcc ${file} -o ${fileBasenameNoExtension} && ./${fileBasenameNoExtension} ",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}