C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 10)
10.
What will be the output of the program ?
#include<stdio.h>
int main()
{
void *vp;
char ch=74, *cp="JACK";
int j=65;
vp=&ch;
printf("%c", *(char*)vp);
vp=&j;
printf("%c", *(int*)vp);
vp=cp;
printf("%s", (char*)vp+2);
return 0;
}
Discussion:
84 comments Page 4 of 9.
Debajyoti MALLICK said:
9 years ago
Thanks @Nilesh and all.
Nice explanation.
Nice explanation.
Shreya said:
9 years ago
In step 2.
printf("%c", *(int*)vp);
Why doesn't it print 65 in place of 'A'?
(since it is typecast to int type and j also holds an integer).
printf("%c", *(int*)vp);
Why doesn't it print 65 in place of 'A'?
(since it is typecast to int type and j also holds an integer).
Azagumozhi.M said:
9 years ago
Thank you, @Nilesh ji. Nice explanation.
Ask said:
9 years ago
Thanks @Nilesh. Your concept is clear to understnd.
Deepak said:
9 years ago
Thank you all, it is very useful.
Shwetha said:
9 years ago
Thanks a lot, @Nilesh. Your method is simple, clear and seemed easy :).
Neel Purohit said:
9 years ago
@Nilesh.
Thank you for the brilliant answer and simple explanation.
Thank you for the brilliant answer and simple explanation.
Akash said:
9 years ago
@Nilesh.
Thank you very mush. Your explanation is clear.
Thank you very mush. Your explanation is clear.
Ponraj said:
9 years ago
@Nilesh.
I understand this with the help of your explanation. Thank you.
I understand this with the help of your explanation. Thank you.
Siya said:
9 years ago
Good explanation. Thank you @Nilesh.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers