· C – Syntax – Variables
- C has four Basic Primitive Types: char, int, float and double.
These can be combined with optional qualifiers: signed,
Not all qualifiers can be used with all Basic Primitive Types.
If unsigned is not specified signed
is presumed for char and int.
When short and long are used with int, int can be
- C also has pointers.
Pointer is variable which holds memory address.
You can define
what type of data is stored at that address or use void instead.
- Primitive Types and Pointers can be declared as constant by using const
This means that variable can't be changed once it is set and must be
initialized when it is declared.
- This tutorial is based on http://en.wikipedia.org/wiki/C_variable_types_and_declarations.
- Primitive Types:
- C doesn't specify exactly how big certain types should be so take
following definitions just as an example.
- Use sizeof() function to find actual size of
primitive types used by your compiler like: sizeof(long int).
- long double is not recognized in all compilers.
char - 8-bit two's complement
- 16-bit two's
- 32-bit two's
- 64-bit two's
unsigned char - 8-bit positive integer
- 16-bit positive
- 32-bit positive
- 64-bit positive
- 32-bit IEEE 754
- 64-bit IEEE 754