Showing posts with label void pointer. Show all posts
Showing posts with label void pointer. Show all posts

Sunday, 29 January 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc – 6

Predict the output or error(s) for the following:


1)

main( )

{

 void *vp;


 char ch = ‘g’, *cp = “goofy”;


 int j = 20;


 vp = &ch;


 printf(“%c”, *(char *)vp);


 vp = &j;


 printf(“%d”,*(int *)vp);


 vp = cp;


 printf(“%s”,(char *)vp + 3);


}

Answer:

g20fy


Explanation: