• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Quiz - 101 | Question 4

C
#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

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments