Writing C Hello world Programs
- A programmer uses a text editor to create or modify files containing C code.
- Code is also known as source code.
- A file containing source code is called a source file.
- After a C source file has been created, the programmer must invoke the C compiler before the program can be executed (run).
#include <stdio.h> /* The simplest C Program */ int main(int argc, char **argv) { printf("Hello World\n"); return 0; } /* OUTPUT: Hello World */
- The main() function is always where your program starts running.
- #include inserts another file. “.h” files are called “header” files. They contain stuff needed to interface to libraries and code in other “.c” files.
- This is a comment. The compiler ignores this.
- Blocks of code (“lexical scopes”) are marked by { … }
- Print out a message. ‘\n’ means “new line”.
- Return ‘0’ from this function
Leave a Reply