Pointer & Arrays
17 October 2018
Pointer
Definition:
Pointer is a
variable that store the address of another variable
Array
Definiton:
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
Syntax
for Pointer:
<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 */
Syntax
for Array:
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 [ ]
Albert TG/2201736385
Binusian2022