In the following example, the boolean True is used in a condition:
We can also initialize a variable with a boolean type:
Pointer types
The Pointer in C, is a variable that stores address of another variable.
The purpose of pointer is to save memory space and achieve faster execution time.
Each variable also has its address.
The address can be retrieved by putting '&' before the variable name.
Synopsis
Here's the syntax to declare pointer:
Addresses
Although all pointers are addresses , we want the type of the pointer to indicate what is being pointed to.
Example
Lets consider this case:
In this case, we can point b at a by using the & operator.
We are assigning to b the address of the integer a;
You can also pass address to function:
You can notice that we use a new operator ?. We will explain right now what is it
Dereferencing Pointers
This example would define a pointer to an integer, and ?p would dereference that pointer, meaning that it would actually designates the memory location where p is defined.
By doing that we can modify a value directly where it is stored, so we don't need to return it in the previous case.
Type casting
Converts between types using a combination of implicit and user-defined conversions.
Synopsis
Here b takes the value of a and converts its type from int to <new-type>.
Example
Here f is a float and c a char and their type is converted to int in i and i2. Here i = 48 (so it's rounded) and i2 = 49.