You don't need a code runner. You can configure VSCode to allow you to run the code and also debug it in a much better way.
Check for GCC
Go to the terminal and type gcc --version into it.
If you get something like this:
Copygcc (Rev1, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It means GCC is installed and should be found by VSCode.
tasks.json
You'd have to give the correct paths to tasks.json to perform the builds and runs. Here's an example
{
"version": "2.0.0",
"tasks" :
[
{
"label" : "build release",
"type" : "shell",
"command": "gcc main.c -O2 -o ${workspaceFolderBasename}.exe"
},
{
"label" : "build debug",
"type" : "shell",
"command": "gcc main.c -g3 -o ${workspaceFolderBasename}.exe"
},
{
"label" : "run_executable",
"type" : "shell",
"command": "./${workspaceFolderBasename}.exe"
}
]
}
This assumes that the executable name you want is the same as your folder name. For example if the folder name is my_c_project then the executable would become my_c_project.exe. You can of course give custom names by replacing ${workspaceFolderBasename}.
To run it or debug it, you'd need GDB. To check for it, use gdb --version in a terminal and it should give you this output.
CopyGNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
And also you'd have to configure the launch configuration.
launch.json
Here's an example
{
"configurations": [
{
"name" : "Debug Config",
"type" : "cppdbg",
"request" : "launch",
"program" : "${workspaceRoot}/${workspaceFolderBasename}.exe",
"args" : [],
"preLaunchTask" : "build debug",
"stopAtEntry" : true,
"cwd" : "${workspaceRoot}",
"environment" : [],
"externalConsole": false,
"MIMode" : "gdb",
}
]
}
The first important bit in it is the program parameter which should point to the program created after building. You can see that the build debug and build release tasks both create the executable at the base folder, (the same place where your main.c is placed). And so the program property of launch.json is also pointing to the same executable.
And the second important bit is the preLaunchTask parameter which tells the debugger to perform a task before it starts debugging. It's been set to the build debug task, so every time you debug, it will rebuild to let you use the latest code.
Once you've set these up, just go to the debug tab and click on the green debug symbol on the top right.

And it would start debugging. Viola!
Answer from Usman Mehmood on Stack OverflowNewbie, windows_NT x64 10.0.17763, vscode 1.40.2, trying to learn C++
After install of vscode I noted at C/C++ Edit Configurations / Compiler path field says (No compiler paths detected).
Learned form vscode website I need to install one. Downloaded mingw-w64 v7. Instruction on various youtube videos say to copy the path from the 'bin' directory within the mingw-w64 folder and paste this into the compiler path field in the compiler path field but there is no such directory called 'bin' in the mingw-w64 folder. Anyone know what I should use as the path for this?
Screen clip of c/c++ compiler config path
From mingw_w64 folder, searched for *bin* (recusively). No directory hits.
