5th Algo Class

Pointers & Arrays

A pointer is a variable that stores the address of another variable rather than a value. To assign a pointer you just have to add an asterisk (*) in front of the variable name. To assign the pointer to another variable’s address then you just have to type in “pointer_var = &var”.

Pointer to Pointer is a variable that stores the address of another pointer by adding an extra asterisk in front of the variable you intend to be a Pointer to Pointer (e.g: **pointer). The input value will be redirected to the address of the Pointer which will again be redirected to the address of a variable.

Array is multiple data saved in a certain structure that can be accessed as a group of individually. An Array is Homogeneous, meaning that the data are similar in type, and is Random Access, meaning that each element can be reached individually. The definition of Array consists of 4 components:

  1. Type (int, char, etc.)
  2. Identifier (name of the array)
  3. Operator index ([ ])
  4. Dimensional value inside Operator (may be left as blank if you decide to insert values initially)

The index of an Array starts from 0, so if say you set the Dimensional value as 3 then it will be: A[0] A[1] A[2]
An array can be made in a multi-dimensional structure (e.g: 1D, 2D, 3D, etc.)

And then something about string, but I fell asleep ’cause I was up all night doing homework xD

Leave a Reply

Your email address will not be published. Required fields are marked *