Murphy's Law dictates that there is no single correct answer to the very first exercise in the book. Oh well. Here's a "hello world" program:
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
As you can see, I've added a
return statement, because main always returns int, and it's good style to show this explicitly. Here's a list of simple compile lines for a variety of popular compilers:
GNU C
gcc -W -Wall -ansi -pedantic -o hello hello.c Microsoft C, up to version 5.1
cl -W3 -Zi -Od -AL hello.c Microsoft C,version 6, Microsoft Visual C++ 1.0, 1.5
cl -W4 -Zi -Od -AL hello.c Microsoft Visual C++ 2.0 and later
cl -W4 -Zi -Od hello.c Turbo C++
tcc -A -ml hello.c (I think) Borland C++, 16 bit versions
bcc -A -ml hello.c Borland C++, 32 bit versions
bcc32 -A hello.c
Nessun commento:
Posta un commento