Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a .C file with arguments ?

Status
Not open for further replies.

N3XuS

Programmer
Mar 1, 2002
339
BE
I'm trying to run a .c file with arguments but if I type like "gcc blah.c 192.168.2.9 -f" it interprets the arguments as a part of "gcc" and not blah.c. I always thought the whole purpose of a compiler was compiling it into an executable not executing it right away ... does it put the executable anywhere or can I make gcc make one ?

thanks in advance
 
[tt]gcc -o blah blah.c[/tt]

then:
[tt]./blah 192.168.2.9 -f[/tt]

gcc is the 'Gnu C Compiler'. It compiles a C source file (typically given a .c extension) into an executable. Then you may run it, passing it arguments from the command line.

----
JBR
 
You don't run a .c file; you compile it.

Trying to pass command line arguments for the program when you're compiling the program is a nonsensical action.


As you say, a compiler compiles source code into executables that can be run later. That is indeed its entire purpose.

By default, if the compiler would make an executable, it names it [tt]a.out[/tt], which stands for "assembler output." You can override this behavior with the -o option, whose use is demonstrated in the previous post.
 
Thanks a lot guys :)
I'm not all too comfy with the whole Linux programmes yet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top