[NTLUG:Discuss] RE: Extremely simple C program...

Preston maillist at inbox.lv
Mon Aug 12 09:49:34 CDT 2002


Hello,

Originally main was always ment to have return type int.  So you could make
main's return type int and then just add the line: return 0; at the end.
Most compilers today don't require this.  You should just try
gcc hello.c

then

./a.out

you can also try not including a return type for main at all.  Most
standard, current implementations of gcc will let you get away with this:

#include <stdio.h>

main()
{
printf("Hello World!");
}

Hope this helps.  If you decide you really like C, I would recommend getting
K & R's The C Programming Language.  It is a little more pricy than other C
books, but you can find it for fairly little on half.com or eBay.  It was
written by the guys who wrote C and it is my favorite C book.

Preston





More information about the Discuss mailing list