contoh program pointer C++

contoh program pointer C++
 #include "stdio.h" 
    #include "conio.h" 
     
    void main() 
    { 
     int *point; 
     int a=7, b=15; 
     
     printf(" Nilai a : %d \n", a); 
     printf(" Alamat a : %p \n\n", &a); 
     
     point=&a; 
     
     printf(" Nilai point = %p \n", point); 
     printf(" Alamat point = %p \n", &point); 
     printf(" nilai rujukan point = %d \n\n", *point); 
     
     *point=10;  // nilai a diganti dengan nilai pointer 
     
     printf(" Nilai point = %p \n", point); 
     printf(" Alamat point = %p \n", &point); 
     printf(" nilai rujukan point = %d \n\n", *point); 
     
     printf(" Nilai a : %d \n", a); 
     printf(" Alamat a : %p \n\n", &a); 
     
     printf(" Nilai B : %d \n", b); 
     printf(" Alamat B : %p \n\n", &b); 
     
     point=&b;   // rujukan pointer diganti rujukan nilai b 
     
     printf(" Nilai point = %p \n", point); 
     printf(" Alamat point = %p \n", &point); 
     printf(" nilai rujukan point = %d \n\n", *point); 
     
     getch(); 
    } 

0 komentar:

Post a Comment

Copyright © 2014 Dunia Naeta All Right Reserved