pointer in c and the c program
Posted
by sandy101
on Stack Overflow
See other posts from Stack Overflow
or by sandy101
Published on 2010-04-08T14:49:49Z
Indexed on
2010/04/08
14:53 UTC
Read the original article
Hit count: 247
Hello, I am studying the pointer and i come to this program ....
#include <stdio.h>
void swap(int *,int *);
int main()
{
int a=10;
int b=20;
swap(&a,&b);
printf("the value is %d and %d",a,b);
return 0;
}
void swap(int *a,int*b)
{
int t;
t=*a;
*a=*b;
*b=t;
printf("%d and%d\n",*a,*b);
}
can any one tell me why this main function return the value reversed . The thing i understood till now is that the function call in c does not affect the main function and it's values .
I also want to know how much the space a pointer variable occupied like integer have occupied the 2 bytes and the various application use and advantages of the pointer ....
plz.... anyone help
© Stack Overflow or respective owner