Re: weird C program output

2006-12-23 Thread Joachim Schipper
On Sun, Dec 24, 2006 at 12:50:10AM +0530, Arun G Nair wrote: > Hi, > > Am a bit confused by the output of the this C program: > > -ptr.c--- > #include > > int > main() > { > int *ptr, x; > > x = 2; > ptr = &x; > > pri

Re: weird C program output

2006-12-23 Thread Arun G Nair
Thanx for the replies. Yeah, its pointing to itself. x=2, *ptr=2, ptr=0xbfbfece0, &x=0xbfbfece0, &ptr=0xbfbfece4 x=2, *ptr=-1077941020, ptr=0xbfbfece4, &x=0xbfbfece0, &ptr=0xbfbfece4 x=2, *ptr=750764012, ptr=0xbfbfece5, &x=0xbfbfece0, &ptr=0xbfbfece4 Thanx once again. -Arun On 12/24/06, Otto Mo

Re: weird C program output

2006-12-23 Thread Miod Vallat
> Am a bit confused by the output of the this C program: > > -ptr.c--- > #include > > int > main() > { > int *ptr, x; > > x = 2; > ptr = &x; > > printf("x=%d, *ptr=%d, ptr=%p, &x=%p\n", x, *ptr, ptr, &x); > > *ptr

Re: weird C program output

2006-12-23 Thread Otto Moerbeek
On Sun, 24 Dec 2006, Arun G Nair wrote: > Hi, > > Am a bit confused by the output of the this C program: > > -ptr.c--- > #include > > int > main() > { > int *ptr, x; > > x = 2; > ptr = &x; > > printf("x=%d, *ptr=%d,

weird C program output

2006-12-23 Thread Arun G Nair
Hi, Am a bit confused by the output of the this C program: -ptr.c--- #include int main() { int *ptr, x; x = 2; ptr = &x; printf("x=%d, *ptr=%d, ptr=%p, &x=%p\n", x, *ptr, ptr, &x); *ptr++; printf("x=%d, *ptr=