CSI 2
CSI 2
Basic data types in C
- Integers:
- char - characters (or digits), 1 byte
- short - 2 bytes
- int - 4 bytes
- long - 8 bytes
- long long - at least 8 bytes
- unsigned - modifier, makes the value >= 0
- signed - modifier, allows the value to be negative
- Real numbers:
- float - 4 bytes, IEEE 754
- double - 8 bytes, IEEE 754
- long double - at least 10 bytes, IEEE 754
Char
The char value is stored as a number indicating the ASCII code of that character.
'\'
- escape character
Special characters
\n
- New line\r
- Carriage return\t
- Horizontal Tab\\
- Backslash
Variables
Declaration - define a variable with a name and find a place for it in memory. Value of the variable before assignment is going to be undefined (aka "junk")
int x;
Assignment - assign a value to the variable (store a value in memory in the corresponding address)
x = 1;
Initialization - combination of declaration and assignment
int x;
x = 1;
// or
int x = 1;