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

Discussion

What are automatic variables initialised to?

  • A.Junk value
  • B.Nothing
  • C.Both (a) & (b)

Answer: A

Correct answer: Junk value

An automatic variable is not initialised: it holds whatever bytes were left on the stack by earlier calls. Reading one before assigning to it is undefined behaviour, and the value is unpredictable - which is why compilers warn about it.

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

Post your comment

Please log in or register to post a comment.