0

I'm playing with a simple console application in Xcode 5, on Yosemite beta. I set a breakpoint and run the program, as in the following screenshot:

Strange console output

  1. As you can observe, the linked list's head is not empty, so why the console has not printed anything? Actually, the output WILL appear, but only after this function returns. Why is that?

  2. Now in the second image, I just hit return and added a black line. But the debugger does not display the head variable already. Why is that?

Strange debugger output

I can just guess that some kind of optimization is happening behind the scenes. Can anyone elaborate on this?

Maxim Chetrusca
  • 2,939
  • 1
  • 28
  • 28
  • 1
    I think your question is related to this one: http://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-strin – HighPredator Aug 13 '14 at 08:23
  • @HighPredator, thx! indeed, it answers my first question. If I add \n or fflush(stdout) it prints immediately. – Maxim Chetrusca Aug 13 '14 at 08:54

0 Answers0