Contoh penggunaan pointer pada C++, dimana nilai pointer didapat dari nilai suatu Array.
#include <iostream.h>
main () {
int x[5]={10,99,23,15,2};
int *px;
cout <<"***********************************" <<endl;
cout <<"| nilai x | nilai px | alamat memori |\n";
cout <<"-------------------------------------------------" <<endl;
for(int i=0;i<=4;i++) {
px = &x[i]; //membaca alamat dari x
cout <<x[i] <<" " <<*px <<" " <<px <<endl;
}
}
Search
Categories
- Part I : Perkenalan (4)
- Part II : Operator (3)
- Part III : Percabangan (materi) (2)
- Part III : Percabangan (program) (4)
- Part IV : Perulangan (meteri) (3)
- Part IV : Perulangan (program) (3)
- Part V : Array (materi) (1)
- Part V : Array (program) (2)
- Penerapan (6)
- Pointer (2)
- Searching (pencarian) (3)
- Typedef (1)
komet bentar gan ikutan rame2 hehehehe
ReplyDelete