Algorithm & Programming – 5th Meeting

Pointers and Arrays:

–Pointer Definition

–Pointer Concept

–Pointer to Pointer

–Array

Pointer Definition

  • Pointer is a variable that store the address of another variable
  • Syntax :

<type> *ptr_name;

  • Two operators mostly used in pointer : * (content of) and & (address of)
  • Example:

Initialize an integer pointer into a data variable:

int i, *ptr;

ptr = &i;

To assign a new value to the variable pointed by the pointer:

*ptr = 5; /* means i=5 */

Array Definition

  • Data saved in a certain structure to be accessed as a group or individually. Some variables saved using the same name distinguish by their index.
  • Array characteristics:

–Homogenous

All elements have similar data type

–Random Access

Each element can be reached individually, does not have to be sequential

  • Syntax:

  type array_value [value_dim];

  • Example :

int A[10];

  • The definition consists of 4 components:

–Type specified

–Identifier (name of the array)

–Operator index ([ ])

–Dimensional value inside operator [ ]

About adrianjsj

18 | Binusian 2019 | Game Application Technology | Devoted to Jesus | No Other Name | Dota 2 Semi-Pro player | From 94 to 62
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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