C Programming: A Modern Approach
incomplete
C Fundamentals
Writing a Simple Program
#include<stdio>
necessary to "include" information about C's standard I/O (input/output) libraryprogram's executable code goes inside
main
, which represents the "main" programprintf
is a function from the standard I/O library that produces a nicely formatted output\n
tellsprintf
to advance to the next line after printing the messagereturn 0;
indicates the program "returns" the value 0 to the operating system when it terminates
Compiling and Linking
create a file name pun.c containing the program
convert the program to a form that the machine can executable
Preprocessing. the program is given to a preprocessor which obeys commands that begin with # (known as * directives*)
Compiling. modified program now goes to a compiler, which translates it into machine instructions (* object code*)
Linking. a linker combines the object code produced by the compiler with any additional code needed to yield a complete executable program. This additional code includes library functions (like printf) that are used in the program
All this is usually automated. In fact, the preprocessor is usually integrated with the compiler.
The commands necessary to compile and link are: