Topic 2 - C Fundamentals Flashcards
Sime C programs have the form:
directives int main(void) { statements }
Every C program relies on 3 key language features:
1) Directives
2) Functions
3) Statements
Before a program can be executed, three steps are usually necessary:
1) Preprocessing
2) Compiling
3) Linking
Define: Preprocessing:
The preprocessor obeys commands that begin with # (known as directives)
Define: Compiling:
A compiler translates the program into machine instructions (object code)
Define: Linking
A linker combines the object code produced by the compiler with any additional code needed to yield a complete executable program
Compiling and Linking: The _____ and _____ are usually integrated within the _____.
preprocessor; linker; compiler.
With filenames for C, is the .c extension required or not.
Required
To compile and link a program called pun.c under Unix, enter the following command in a terminal at command-line promo:
cc pun.c
What is automatically done when “cc” is invoked?
Preprocessing and linking are automatic when using cc.
After compiling and linking the program, what happens?
cc leaves the executable program in a file named a.out by default
What does -o option do
choose the name of the file containing the executable program
Give the command to choose the name “pun” for the output file when you compile the program pun.c
cc -o pun pun.c
or
cc pun.c -o pun
What happens before a C program is compiled?
It is first edited by a preprocessor.
Commands intended fro the preprocessor are called ______
Directives
What character do directives start with?
A hashtag (#) character
Examples of directives:
include
What is
A header containing information aboutC’s standard I/O library
By default, each directive is how many lines long?
One line long
Are there any semicolons besides directives?
No and no other special marker at the end either
What is a function?
A series of statements that have been grouped together and given a name
A function that computes a value uses a____
return statement to specify what value it returns