33 lines
1.5 KiB
Markdown
33 lines
1.5 KiB
Markdown
# Compilation Steps
|
|
|
|
1. Preprocessing: The preprocessor obeys commands that begin with #, also known as directives
|
|
Commands for the preprocessor are called directives. Directives begin with a pound sign, and they do not end with a semicolon.
|
|
|
|
Example:
|
|
```c
|
|
#include <stdio.h>
|
|
```
|
|
2. Compiling. A compiler translates then translates the program into machine instructions.
|
|
3. Linking: The generated objects are combined to create a complete executable.
|
|
|
|
The preprocessor is typically integrated with the compiler.
|
|
|
|
# Types
|
|
## Strings
|
|
A string literal is characters enclosed in double quotation marks.
|
|
|
|
A newline can be inserted using `\n`.
|
|
|
|
## Integers
|
|
An integer is a way to store a whole number. In C, integers are signed by default.
|
|
## Floats
|
|
A float is a decimal value. Slower arithmetic and inexact values are both drawbacks of using floats.
|
|
## Variables
|
|
A variable must be declared before it is assigned.
|
|
|
|
|
|
# Formatting specifiers
|
|
| Specifier | Function |
|
|
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `%d` | Display an integer |
|
|
| `%f` | Display a float. Specify the number of places to round to by adding a decimal and a number, eg `%.2f` would round to two decimal places. | |