InterviewSolution
Saved Bookmarks
| 1. |
#include "stdio.h"int main(){void *pVoid;pVoid = (void*)0;printf("%lu",sizeof(pVoid));return 0;}Pick the best statement for the above C program snippet.(A) Assigning (void *)0 to pVoid isn’t correct because memory hasn’t been allocated. That’s why no compile error but it’ll result in run time error.(B) Assigning (void *)0 to pVoid isn’t correct because a hard coded value (here zero i.e. 0) can’t assigned to any pointer. That’s why it’ll result in compile error.(C) No compile issue and no run time issue. And the size of the void pointer i.e. pVoid would equal to size of int.(D) sizeof() operator isn’t defined for a pointer of void type. |
| Answer» | |