Created
April 8, 2014 09:19
-
-
Save mie00/10103814 to your computer and use it in GitHub Desktop.
Dosoky c
This file contains 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> | |
void change(int* xp){ //define "declare" pointer called xp , type "int*" NOT "int" | |
printf("0:%d\n",*xp); //print x - the value which pointer points to - old value | |
*xp=6; // change the value of x - using its addr - | |
printf("1:%d\n",*xp); //print x - the value which pointer points to - new value | |
printf("5:%p\n",xp); // print the pointer " the addr of var. x" | |
printf("2:%p\n",&xp); //print the addr of the pointer xp | |
} | |
int main(){ | |
int x=5; | |
printf("4:%p\n",&x); //print the addr of int x " x pointer" | |
change(&x); // send the addr of int x to change fn | |
printf("3:%d\n",x); //print the value of int x - the new value- | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment