Created
March 13, 2013 09:49
-
-
Save honux77/5150644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| /**pointer.c | |
| Should build by release mode. | |
| */ | |
| { | |
| int num1; | |
| int *ptr_l1; | |
| int **ptr_l2; | |
| printf("=================declared, but not initialize=================\n"); | |
| printf(" ptrl2 ptrl1 num1\n"); | |
| printf(" [ ] [ ] [ ]\n\n"); | |
| printf("addr of num1= %p, val= %08X\n", &num1, num1); | |
| printf("addr of ptr_l1= %p, val= %p\n", &ptr_l1, ptr_l1); | |
| printf("addr of ptr_l2= %p, val= %p\n", &ptr_l2, ptr_l2); | |
| ptr_l2 = &ptr_l1; | |
| ptr_l1 = &num1; | |
| num1 = 0xBADBAB0; | |
| printf("\n=================after initializing=================\n"); | |
| printf(" ptrl2 ptrl1 num1\n"); | |
| printf(" [ +-]----->[ +-]----->[0XBA..]\n\n"); | |
| printf("addr of num1= %p, val= %08X\n", &num1, num1); | |
| printf("addr of ptr_l1= %p, val= %p, *val= %08X\n", &ptr_l1, ptr_l1, *ptr_l1); | |
| printf("addr of ptr_l2= %p, val= %p, *val = %p, **val=%08X\n" , &ptr_l2, ptr_l2, *ptr_l2, **ptr_l2); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment