Vote Up 0 Vote Down

run c program in ubuntu

How to run c program using terminal ???
flag

Answers


Vote Up 0 Vote Down
Lets say your program is test.c then for
Compilation:

 gcc -o test.out test.c


To Run:

 ./test.out
flag | link |
Vote Up 0 Vote Down
1)First compile it using

gcc : gcc file_name.c


2)

./a.out 


(for runing the prgm.)
flag | link |
Vote Up 0 Vote Down
To run c program first of all you have to compile with gcc compiler
gcc
./a.out it is to run the program
example--

 gcc demo.c
./a.out


or another method

 gcc demo.c -o ss
./ss


here ss can be replaced by any name. ss is a binary file that is created when we compile the file with gcc
another example--

 gcc demo.c -o demo
./demo</your>
flag | link |
Vote Up 0 Vote Down
First you need to make sure it has execution rights. Then just type in terminal: ./programname

To make a file executable and runnable by any user:

chmod a+x myfile
flag | link |

Your Answer

Login before answering

Login with facebook