Re: [algogeeks] problem regarding output??

2011-08-10 Thread Arun Vishwanathan
@ankit: does that mean that after the compiler is informed that the void pointer will point to integer witht he typecast statement and then we point it to some other type , it will be an error? i mean after that typecast statement, if i do char a; k=a;is it wrng? On Tue, Aug 9, 2011 at 2:06

[algogeeks] problem regarding output??

2011-08-09 Thread Rajesh Kumar
why j and k point different location? #includestdio.h main() { int a=10,*j; void *k; j=k=a; k=(int *)k; k++; j++; printf(%u %u\n,j,k); } -- Regards Rajesh Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] problem regarding output??

2011-08-09 Thread ankit sambyal
its because void pointer is incremented by 1, when we do k++ whereas integer pointer is incremented by 4, when we do j++ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] problem regarding output??

2011-08-09 Thread Rajesh Kumar
thanx Ankit On Tue, Aug 9, 2011 at 5:27 PM, ankit sambyal ankitsamb...@gmail.comwrote: its because void pointer is incremented by 1, when we do k++ whereas integer pointer is incremented by 4, when we do j++ -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] problem regarding output??

2011-08-09 Thread ankit sambyal
The typecasting tells the compiler that the void pointer is now pointing to an integer and when we use this pointer to access the integer it takes value from 4 bytes. But when we try to increment that pointer, it will point to the next byte. Try taking k as pointer to double instead of void, u

Re: [algogeeks] problem regarding output??

2011-08-09 Thread Rohit Srivastava
typecast only temporarily changes the pointer type of LHS but cannot change that of RHS or even LHS permanently On Tue, Aug 9, 2011 at 5:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: The typecasting tells the compiler that the void pointer is now pointing to an integer and when we use this

Re: [algogeeks] problem regarding output??

2011-08-09 Thread Raman
I read somewhere that arithmetic operations can't be performed to void pointers?? How does v++ does'nt giv error?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit