Created
October 16, 2016 09:52
-
-
Save afcidk/1621b0183f0e4e908d5b546831c30eef 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> | |
void wrong_change(int); | |
void correct_change(int*); | |
int main() { | |
int number = 5; | |
printf("the number now is : %d\n",number); | |
wrong_change(number); | |
printf("the number now is : %d\n",number); | |
correct_change(&number); | |
printf("the number now is : %d\n",number); | |
return 0; | |
} | |
void wrong_change(int number) { | |
int num; | |
num = number; | |
num++; | |
} | |
void correct_change(int *addr) { | |
int *num; | |
num = addr; | |
*num = 6; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment