How to Compile C file in Windows using Command Line
📌Prerequisites
Before you start coding in C, you should have a compiler installed in your PC.
But what I recommend is, it’s good to install Visual Studio.
It’s an IDE integrated Development environment which has full support for editors, resource managers, debuggers and compilers for many languages.
You can install Visual Studio Community Edition. It’s FREE. 🆓
After you have installed, you should verify whether all the required tools have installed and you can use access through the command line.
To verify, go to start and find Developer Command Prompt for Visual Studio inside Visual Studio 2019 folder. It will open up the below window.
Then, type cl and enter in command prompt.
If you see an output like this, you have set the Visual C++ developer command prompt correctly.
1. Create
Open notepad and type simple helloworld program.
Save the file as helloworld.c
Now, if you see the folder, it should look like,
2. Compile
First thing before entering the compiling command, you should change the directory to where you have saved the C file.
To change directory, go to Visual C++ developer command prompt, and type the command like,
Here, you have to give your file’s location.
Once you have entered this command, you will see that directory now has changed to your file’s location.
Now enter the command to compile as below.
If you don’t have any errors in your code, you will see an executable program helloworld.exe
Check the file’s location as well. You would see an helloworld.exe application and a 3D object file.
3. Run
Here you will see the output 😍
If you find any difficulties regarding this, raise your doubts in the comments. 😵
Thank you.
0 comments:
Post a Comment