Created
April 24, 2012 14:07
-
-
Save lynxerzhang/2479967 to your computer and use it in GitHub Desktop.
c point study -- (exchange two variable value)
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
/** | |
* The c point study notes | |
* below is a exchange two specified variable value case | |
*/ | |
//this function is do not return any value | |
//the two parameter is a pointer variable of type int | |
void exchangeNum(int *num1, int *num2){ | |
int t = *num1; | |
*num1 = *num2; | |
*num2 = t; | |
} | |
int a = 2; //define a 32-bit int variable | |
int b = 3; //define a 32-bit int variable | |
exchangeNum(&a, &b); //the symbol "&" is mean get that int variable's memory location | |
printf("%i %i", a, b); //we found a, b value is change |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
learning...