W
wilson
Hi All,
I am a novice at C and just have learned pointer for a short period.
Today one error had occured while executing my program below.
And I cannot find the error out since it's checked "OK" by Dev C++.
Here is
I want to exchange the value of "a" and "b" with function "swap")
void swap(int *pa, int *pb)
{
int *tmp;
*tmp = *pa;
*pa = *pb;
*pb = *tmp;
}
// ---------------------------
int main()
{
int a=10, b=20;
printf("a=%d b=%d\n",a,b);
swap(&a, &b);
printf("a=%d b=%d\n",a,b);
system("PAUSE");
return 0;
}
I am a novice at C and just have learned pointer for a short period.
Today one error had occured while executing my program below.
And I cannot find the error out since it's checked "OK" by Dev C++.
Here is
void swap(int *pa, int *pb)
{
int *tmp;
*tmp = *pa;
*pa = *pb;
*pb = *tmp;
}
// ---------------------------
int main()
{
int a=10, b=20;
printf("a=%d b=%d\n",a,b);
swap(&a, &b);
printf("a=%d b=%d\n",a,b);
system("PAUSE");
return 0;
}