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
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
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));
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
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
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