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

Discussion

What is the output of this C code?

int main()
    {
        auto i = 10;
        const auto int *p = &i;
        printf("%d\n", i);
    }

 

  • A.10
  • B.Compile time error
  • C.Depends on the standard
  • D.Depends on the compiler

Answer: A

Correct answer: 10

auto i = 10; relies on the old implicit int, and const auto int *p combines a qualifier with a storage class, which is allowed. The program prints 10 - though a modern compiler will warn, since C99 removed implicit int.

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

Post your comment

Please log in or register to post a comment.