Skip to content

Instantly share code, notes, and snippets.

@afcidk
Created October 16, 2016 09:52
Show Gist options
  • Save afcidk/1621b0183f0e4e908d5b546831c30eef to your computer and use it in GitHub Desktop.
Save afcidk/1621b0183f0e4e908d5b546831c30eef to your computer and use it in GitHub Desktop.
#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