Skip to content
Home » How to run C Program from Terminal?

How to run C Program from Terminal?

Running C Program from the terminal might be difficult for many new developers and programmers but believe me, it’s very easy than it looks.

Basically, you just need to follow 3 steps to run your C Program from Terminal!

PreRequisites

You need to have gcc installed on your system and make sure to set up the path on your windows machine:P

You can check if gcc is installed or not via:

gcc -v

The result of the code might differ according to the OS and the version of gcc

If your system has gcc then you can proceed to next step😉

1. Save a file with a .c extension in it

Here, I have saved my code in “program.c” filename on my desired path.

2. Compile your code

gcc filename.c -o filename

This will compile your code and create an executable named filename!

Here you can see a new file program is being created which is an executable file.

3. Run the program

./filename

You can run the program by executing the executable file

Horray! You have successfully executed your program from the terminal🥳
Hope it has helped you!

How is the blog?
+1
1
+1
1
+1
14
+1
1
+1
0
+1
2
5 4 votes
Article Rating
Subscribe
Notify of
guest
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Susan Adhikari

Really Helpful!

Satya Raj Awasthi

Great, recommend everyone to try using command. It wil surely give another level experience.

Pravin kumar bogati

Very Helpful. We are expecting more blogs on file system of Unix like OS.

Hemraj Pant

thanks daju ❤️

7
0
Would love your thoughts, please comment.x
()
x