How to run C program
2025-08-04
How to run C program on windows
- Visual studio has a built-in C compiler.
- Run
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
in cmd to set up the environment. Note: It cannot run on powershell 7+. - Use
cl
command to compile C files, e.g.,cl test.c -o test.exe
. - Run the compiled program with
test.exe
.
Alternative or must way on Windows
- Use developer powershell for VS2022 will resolve the above hacks.
- Just open a new terminal with
Developer Command Prompt for VS 2022
orDeveloper PowerShell for VS 2022
. - Then
cl
command will work without any additional setup.