Machine-translated by Google. Questions are authored in English.
Top

Discussion

The following program reports an error on compilation.

#include <stdio.h>
int main()
{
    float i=10, *j;
    void *k;
    k=&i;
    j=k;
    printf("%f\n", *j);
    return 0;
}

 

  • A.True
  • B.False

Answer: B

Correct answer: False

The program compiles cleanly. In C a void * converts to and from any object pointer type implicitly, so k = &i; and j = k; both need no cast, and the value printed is 10.000000. C++ is the language that would require an explicit cast on the second assignment; C deliberately does not.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.