[algogeeks] Explain Output

2011-09-29 Thread Brijesh
void main() { void *ptr; char *a='A'; char *b=TAN; int i=50; ptr=a; ptr=(*char)malloc(sizeof(a)); printf(%c,*ptr); ptr=i; ptr=(*int)malloc(sizeof(i)); printf(%d,++(*ptr)); ptr=b; ptr=(*char)malloc(sizeof(b)); printf(%c,++(*ptr)); } Ans: A51AN Please explain the output.. Doesnt this line

[algogeeks] Explain output

2011-09-29 Thread Brijesh
void main() { void *ptr; char *a='A'; char *b=TAN; int i=50; ptr=a; ptr=(*char)malloc(sizeof(a)); printf(%c,*ptr); ptr=i; ptr=(*int)malloc(sizeof(i)); printf(%d,++(*ptr)); ptr=b; ptr=(*char)malloc(sizeof(b)); printf(%c,++(*ptr)); } ptr=(*char)malloc(sizeof(a)); Ans: A51AN Please explain the

Re: [algogeeks] Explain output

2011-09-29 Thread Kunal Patil
Why don't you post a code that compiles ? On Fri, Sep 30, 2011 at 12:41 AM, Brijesh brijeshupadhyay...@gmail.comwrote: void main() { void *ptr; char *a='A'; char *b=TAN; int i=50; ptr=a; ptr=(*char)malloc(sizeof(a)); printf(%c,*ptr); ptr=i; ptr=(*int)malloc(sizeof(i));

Re: [algogeeks] Explain output

2011-09-29 Thread praveen raj
Ptr cannot be used to allocate block of memory .. void pointer use only to store address... -- 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 unsubscribe from this group, send

Re: [algogeeks] Explain output

2011-09-29 Thread rahul sharma
ptr is givenc char addrsss so print A ptr given int address but ++(*ptr) increments that int val so it goes 51 next ptr contains char address of char but i think ++(*ptr) gives ua insetead un an On Fri, Sep 30, 2011 at 9:24 AM, praveen raj praveen0...@gmail.com wrote: Ptr cannot be used to

Re: [algogeeks] Explain output

2011-09-29 Thread rahul sharma
n in last it prints an of o/p a51an but only %c used so i thhink somethng wrngexplain nyone plz On Fri, Sep 30, 2011 at 10:34 AM, rahul sharma rahul23111...@gmail.comwrote: ptr is givenc char addrsss so print A ptr given int address but ++(*ptr) increments that int val so it goes