30 lines
		
	
	
		
			732 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			732 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <stdio.h>
 | |
| int main(int argc, const char *argv[])
 | |
| {
 | |
|     // Define a pointer
 | |
|     int* p;
 | |
|     // We make p point to another variables value:
 | |
|     int a = 2;
 | |
|     // Initializing the pointer
 | |
|     p = &a;
 | |
|     
 | |
|     // Print value our pointer points to
 | |
|     printf("Value of p: %d\n", *p);
 | |
|     // Print the pointers Memmory adress
 | |
|     printf("Adress of p: %p\n", p);
 | |
|     
 | |
|     
 | |
|     // Access the value of p
 | |
|     *p = 42;
 | |
|     // The value of a is changed
 | |
|     // p points to the memory a is stored in
 | |
|     printf("Value of a: %d\n", a);
 | |
|     printf("Value of p: %d\n", *p);
 | |
| 
 | |
|     a = 27;
 | |
|     // You can also change the value of a
 | |
|     // and the value of p will change
 | |
|     printf("Value of a: %d\n", a);
 | |
|     printf("Value of p: %d\n", *p);
 | |
| }
 |