DEKLARASI POINTER POINTER

Seperti halnya variabel yang lain, variabel pointer juga harus dideklarasikan terlebih dahulu sebelum digunakan.

Contoh:
int *a; atau int* a;
char *ket; atau char* ket;



int *px;
char *sh;
Contoh Program :
#include “IOSTREAM.h”
#include “conio.h”
void main()
{ int x, y; /* x dan y bertipe int */
int *px; /* px pointer yang menunjuk objek */
clrscr();
x = 87;
px = &x; /* px berisi alamat dari x */
y = *px; /* y berisi nilai yang ditunjuk px */
cout<<“Alamat x =”<<&x <<\n”;
cout<<“Isi px = \n”, px);
cout<<“Isi x = \n”, x);
cout<<“Nilai yang ditunjuk oleh px = \n”, *px);
cout<<“Nilai y = \n”, y);
getch();
}

No comments:

Post a Comment