Monday 2 March 2015

Studi tentang Pointer di bahasa pemrograman C

Pointer hanya untuk memunculkan alamat memori dari suatu variabel. 

1. Asteriks dari suatu alamat memori memunculkan nilai yang terkandung di dalam alamat memori yang diassign itu.
1. Asteriks dari suatu variabel adalah nilai yang terkandung di dalamnya.
2. Ampersand dari suatu variabel adalah nilai alamat memori pengandung nilai dari variabel itu.
3.

Langkah-langkah:
1. Deklarasikan x
int x;
2. Beri nilai ke dalam x
x = 10;
3. Deklarasikan pointer j
int *j;
4. Berikan nilai ke dalam p (hanya berikan nilai variabel)
j = &x;
5. Tampilkan nilai j
6. tampilan *j
7. tampilkan alamat memori variabel j


#include 
int main() 

 int x = 10; 
 int *j; 
 j = &x; 

 printf("The value of x is %d\n",x); 
 printf("The address of x is i.e &x is %p\n",&x); 
 printf("The value of x is i.e *(&x) %d\n\n",*(&x)); 

 printf("The memory address stored in the pointer j is %p\n",j); 
 printf("The value pointed by the pointer j is %d\n",*j); 
 printf("The address of pointer j is %p",&j); 
 getch(); 
 return 0; 
}

D:\God Bless Me Learn C\pointer>pointer2.exe
The value of x is 10
The address of x is i.e &x is 0028FF0C
The value of x is i.e *(&x) 10

The memory address stored in the pointer j is 0028FF0C
The value pointed by the pointer j is 10
The address of pointer j is 0028FF08



Pointer to pointer
Pointer to pointer is a variable that gonna contain the address of another variabel.



nknk

No comments:

Post a Comment