void swap(int *x, int *y) {
int temp;
temp = *x;
*x = *y;
*y = temp;
}
int main() {
int a=10, b=20;
swap(a, b);
printf("a: %d, b: %d", a, b);
}
I have error when it runs ..
它运行时我有错误..
1 个解决方案
#1
1
u have to pass reference to swap method not values .
你必须传递对swap方法的引用而不是值。
int a=10, b=20;
swap(&a, &b);
#1
1
u have to pass reference to swap method not values .
你必须传递对swap方法的引用而不是值。
int a=10, b=20;
swap(&a, &b);