#include <stdio.h>
#include <stdlib.h>
int main(void)
{ printf("Hello World!\n");
return EXIT_SUCCESS;
}
Assume that it is stored in a file called hello.c in the current working directory.
Then:
$ gcc -o hello hello.c
(Note: Compiles without warning or error)
$ ./hello
Hello World!
We are including two header files from the standard library
– stdio.h contains declarations for buffered, stream-based input and output
(we include it for the declaration of printf)
– stdlib.h contains declarations for many odds and ends from the standard
library (it gives us EXIT SUCCESS)
– In general, preprocessor directives start with a hash #
– A return statement, returning the value of the symbol EXIT SUCCESS to the
caller of main()
0 comments: