Tuesday 21 February 2012

Pointers.

Today I have learn about Pointers - because function can only return one data.

int i = 3; [address of variable : &i   = 65524]
             [value at address :     *(&i)  = 3 ]
             # the sign *( ) si called pointers.
declaring pointer - pointer variables:
int *alpha ;  //integer pointer
char *ch ;  // char pointer
float *s  ;  //float pointer

Example of call by reference:

void main (void)
{
int a = 10, b = 20;
swap (&a, &b);
printf ("a = %d, b=%d\n", a, b);
}
void swap ( int *x, int *y)
{
int t;
swap (&a, &b);
t=*x;
*x=*y;
*y=t;
}

And am doing some exercise :

Get radius, calculate area and parameter using one function only.

Also am doing this exercise :

Add caption