Linux之Hello World

 

1  Source code  hello.c

1 /* hello.c */

2 #include <stdlib.h>

3 #include <stdio.h>

4 

5 int main()

6 {

7   printf("Hello World!\n");

8   exit(0);

9 }

 

2  Compile, link and run

$ gcc -o hello hello.c

$ ./hello

Hello World!

 If you forget the -o name option that tells the compiler where to place the executable, it will place the program in a file called a.out (meaning assembler output). 

你可能感兴趣的:(Hello world)