Algoritma 5

Pointers & Array (29 Oktober 2015)

Defenition:Pointer is a variable that states the adress of another variable.

2 operators mostly used in pointer:*(content of) and & (adress of)

Example:int i,*ptr;

ptr=&i;

(To assign a new value pointed by the pointer:*ptr=5;/* means i=5*/)

*=konten variabel lain

tanpa *=menyimpan nilai variabel itu tapi harus menggunakan variabel lain

Pointer to pointer:A variable that saver another adress of a pointer.

Array definition

Data saved i a certain structure to be accesed as a group or individually.Some variable saved using the same name distinguish by their index.

Characteristic:

-Homogenous(All elements have similar data type)

-Random Access(Each element can be reached individualy,does not have to be sequential)

Array Initialization

Array can be initialized explicitly without dimensional value declaration.

Accsesing Array

-Two analougous ways of accesing an element 1=2;

*(A+2) or A[2]

-A is equivalent with &A[0] or a constant pointer to the first element of particular array.

Pointer Constant & Pointer Variable

-Pointer Variable:a pointer that can be assigned with new value at run-time

-Pointer Constant:a pointer that cannot be assigned with new value at run-time

One dimensional array

-C compiler does not limit number of dimensional which can be created.Our PC memory does.

Two dimension array

Inialization:using rmo(row major order)

Array of pointer:array filled with pointer/s

Array of character:Array filled with character/s

String:An array of character that ended with null character(’10’ or m ASCII=0).

 

Leave a Reply

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