c program pointer

Posted by sandy101 on Stack Overflow See other posts from Stack Overflow or by sandy101
Published on 2010-04-27T18:38:15Z Indexed on 2010/04/27 18:43 UTC
Read the original article Hit count: 249

Filed under:
|
|

Hello , I am trying some programs in c face a problem with this program

#include<stdio.h>

int main()

{

int a=9,*x;

float b=3.6,*y;

char c='a',*z;

printf("the value is %d\n",a);

printf("the value is %f\n",b);

printf("the value is %c\n",c);

x=&a;

y=&b;

z=&c;

printf("%u\n",a);

printf("%u\n",b);

printf("%u\n",c);

x++;

y++;

z++;

printf("%u\n",a);

printf("%u\n",b);

printf("%u\n",c);

return 0;

}

can any one tell me what is the problem with this and i also want to know that when in the above case if the pointer value is incremented then will it over write the previous value address as

suppose that the value we got in the above program (without the increment in the pointer value )is 65524 65520 65519 and after the increment the value of the pointer is 65526(as 2 increment for the int ) 65524(as 4 increment for the float ) 65520(as 1 increment for the char variable )

then if in that case will the new pointer address overwrite the content of the previous address and what value be contained at the new address ......plz help

© Stack Overflow or respective owner

Related posts about c

    Related posts about program