传值传值传引用探讨
void swap_int(int a , int b){
int temp = a;
a = b;
b = temp;
}
void swap_str(char* a , char* b)
{
char* temp = a;
a = b;
b = temp;
}
int main(void)
{
int a = 10;
int b = 5;
char* str_a = "hello world";
char* str_b = "world hello";
swap_int(a , b);
swap_str(str_a , str_b);
printf("%d,%d\n",a,b);
printf("%s,%s\n",str_a,str_b);
return 0;
}
正确答案是什么呢
页:
[1]