Login Register






C compilation! filter_list
Author
Message
C compilation! #1
Learning C in linux.

The simple hello world.

Code:
#include <stdio.h> main() { printf("Hello, world!\n"); return 0; }

Then why trying to compile it using.

Code:
gcc -o hello.c

It gives an error of
Code:
gcc: fatal error: no inpurt files compileation terminated







Reply

RE: C compilation! #2
well lets look at this command you're running

gcc -o hello.c

gcc -> Now gcc is pretty obvious i guess. thats the name of the compiler

-o -> this is an argument/switch/option/whatever you want to call it. This one tells the compiler what it should save the output/compiled application as on the hard disk. its the output of the compilation you are running

so right now you are telling it to save the gcc output to hello.c

how does the compiler know what to compile? you havent specified the file you want to compile, only the file you want when its done. Its not a mind reader - you need to tell it what file to compile!

Reply

RE: C compilation! #3
Use this Command:
Code:
gcc hello.c -o hello

And to run it, just enter the filename:
Code:
hello
[Image: MUJ8qSW.png]
-----------------------------------
Now learning:
Android Development, Java
Working on:
An FTP Client for Android
-----------------------------------

Reply

RE: C compilation! #4
As above really, but one more thing you should always make sure that main is of type int
Code:
int main(void)

although it will compile it's considered bad practice.
If you need help feel free to PM me
[Image: klfpJD]
Probitcoin
Freebitcoin
BTC clicks
bitcoin wallet:
1FBPAanbs3rJU9BUpobpDJc9hHUaCaC25N

Reply

RE: C compilation! #5
(06-21-2014, 03:16 PM)chmod Wrote: As above really, but one more thing you should always make sure that main is of type int
Code:
int main(void)

although it will compile it's considered bad practice.

I thought
Code:
void

does not work with all compilers?







Reply

RE: C compilation! #6
(06-21-2014, 03:33 PM)BlueCat Wrote:
(06-21-2014, 03:16 PM)chmod Wrote: As above really, but one more thing you should always make sure that main is of type int
Code:
int main(void)

although it will compile it's considered bad practice.

I thought
Code:
void

does not work with all compilers?

void is not strictly required (force of habit) and you should not get any problems using it with gcc or any other compiler, all it means is that the function, in this case main does not take any arguments, however it will still return an integer value (0) so should be of type int.
If you need help feel free to PM me
[Image: klfpJD]
Probitcoin
Freebitcoin
BTC clicks
bitcoin wallet:
1FBPAanbs3rJU9BUpobpDJc9hHUaCaC25N

Reply