hwo to execute C programs in linux
I just started using my new sams teach yourself c in 24 hours book. It's great but one problem is it doesn't explain how to execute c programs in linux. I can compile what ever I do, but how do I execute it so I can get the output?
thanx Gonus |
To compile:
gcc -o output_file my_source_file.c To run: ./output_file |
when you've compiled the program, just run it with
./programname if you've not set a name, it'll normally be called a.out |
ok. its name is a.out to compile and have it named somethingelse
gcc -o somethingelse hello.c then to run ./somethingelse is that correct? Will a.out still run? thanx |
The commands you just wrote will get you a program named 'somethingelse'. There will be no a.out. To run your program, just type ./somethingelse , as the others said :).
|
Thank you.
Gonus |
after typing out your source code in an editor such as vi or emacs just save the file as 'programname.c' then compile it with
gcc -o programname programname.c then run it with ./programname :) |
Why not make it simple:
gcc progname.c ./a.out |
i'm lost now... the last two posts have just repeated the same things that have already been said... :confused:
|
Not exactly... One used -o option. It allows you to specify the name of resulting file. If there's no -o option, a.out is created.
<Edit> Whoops.. I've written it after reading 3 last posts...</Edit> |
All times are GMT -5. The time now is 05:18 PM. |