·  C – Syntax – Variables


- Info:

  - C has four Basic Primitive Types: char, int, float and double.

    These can be combined with optional qualifiers: signed, unsigned, short or long.

    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 ommited.

  - 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 qualifier.

    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

             short     - 16-bit two's complement

             int       - 32-bit two's complement

             long      - 64-bit two's complement


    unsigned char      -  8-bit positive integer

    unsigned short     - 16-bit positive integer

    unsigned int       - 32-bit positive integer

    unsigned long      - 64-bit positive integer


             float     - 32-bit IEEE 754

             double    - 64-bit IEEE 754