diff --git a/llo-index.yml b/llo-index.yml index de06300..7662246 100644 --- a/llo-index.yml +++ b/llo-index.yml @@ -12,7 +12,7 @@ info: subdir: "" asciidoc: "adoc" - file: "nmap.adoc" + file: "hello.adoc" mimetype: "text/x-python" code: subdir: "" diff --git a/swarmlab/llo/hello.adoc b/swarmlab/llo/hello.adoc new file mode 100644 index 0000000..0d86771 --- /dev/null +++ b/swarmlab/llo/hello.adoc @@ -0,0 +1,24 @@ +The classic example program for the C language is Hello World. Here is the source code for our version of the program: + +[source,c] +---- +#include + +int +main (void) +{ + printf ("Hello, world!\n"); + return 0; +} +---- + +This compiles the source code in 'hello.c' to machine code and stores it in an executable file 'hello'. The output file for the machine code is specified using the -o option. This option is usually given as the last argument on the command line. If it is omitted, the output is written to a default file called 'a.out'. + +Note that if a file with the same name as the executable file already exists in the current directory it will be overwritten. + +The option -Wall turns on all the most commonly-used compiler warnings---it is recommended that you always use this option! There are many other warning options which will be discussed in later chapters, but -Wall is the most important. GCC will not produce any warnings unless they are enabled. Compiler warnings are an essential aid in detecting problems when programming in C and C++. + +In this case, the compiler does not produce any warnings with the -Wall option, since the program is completely valid. Source code which does not produce any warnings is said to compile cleanly. + + +