[NTLUG:Discuss] Extremely simple C program...
Wayne Dahl
w.dahl4 at verizon.net
Sat Aug 10 23:19:51 CDT 2002
Lessee...how many irons can I get in the fire?
Ok...I'm attempting to learn C for the very first time (I'm no
programmer and I can hear the laughter now) from a book. Here's the
first simple program it gives...
/* Example 1.1 Your Very First C Program - Displaying Hello World */
#include <stdio.h>
void main()
{
printf("Hello world!");
}
So far, so good. After writing that in gedit and saving it as hello.c,
I issue gcc -c hello.c and get these messages...
hello.c: In function `main'
hello.c:6: warning: return type of `main' is not `int'
Then, when I attempt to link the two by using gcc hello.c hello.o, I get
these messages...
hello.c: In function `main'
hello.c:6: warning: return type of `main' is not `int'
hello.o: In function `main'
hello.o(.text+0x0): multiple definition of `main'
/tmp/ccBEHACq.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
It does not create an a.out file. It doesn't seem to do anything at all
but return the error messages. This is an extremely simple
program...and I can't get it to work. :Þ At this rate, I'll never
learn C or anything else! Unfortuately, the book I'm using (Ivor
Horton's Beginning C Programming) doesn't account for a possible problem
with the compiler. I don't see anything wrong with what I'm doing
(obviously, or I wouldn't be asking for your input), but there's surely
something wrong here. Any help would be appreciated.
Thanks,
Wayne
More information about the Discuss
mailing list