Preprocesso
Source code Object code
r/
file2.c Compiler file2.o
Libraries
Linker
Executable
code
a.out
5 CS 3090: Safety Critical Programming
in C
Separate compilation
Advantage: Quicker compilation
When modifying a program, a programmer
typically edits only a few source code files at a
time.
With separate compilation, only the files that have
been edited since the last compilation need to be
recompiled when re-building the program.
For very large programs, this can save a lot of
time.
If you don’t like this name, choose another using the –o option:
cc program.c –o exciting_executable
Preprocesso
Compiler
r
int
main( void )
{ …
%d (print as integer),
Make sure you pick
%f (print as floating-point)
the right one!
\n indicates a newline character Text line printed only
when \n
encountered
Don’t forget \n
18 CS 3090: Safety Critical Programming
when
in C printing “final
return vs. exit
Let’s look at the return statement in main():
return EXIT_SUCCESS;
p o i n t e r NUL
(char) (char) (char) (char) (char) (char) (char) (char)
(char *)
How do we get to the “n”?
What is input? input Follow the input pointer,
It’s a string! then hop 3 to the right
It’s a pointer to *(input + 3)
char! - or -
It’s an array of input[3]
char!