Xcode does not print without a line break

0

A code that simple ... From one day to the next Xcode does not print anything without adding a \n to the end of the string.

The same thing happens in c ++, it does not print without a endl .

#include <stdio.h>

int main()
{
  printf("Hola mundo!");
  return 0;
}
    
asked by Franco Ramirez 05.04.2017 в 06:26
source

2 answers

0

printf does not write to the console but to the output buffer. This buffer can be directed to the console itself, but also to a file or even to a printer.

The important thing is that you do not write directly on a device but on a buffer. For the information to end in the output device, it is necessary that said buffer dump the information in said device. As long as that does not happen, the output device will not show anything.

How do you dump the contents of the buffer to the output device?

The most basic way is to call the corresponding flush method. In C ++, for example, std::endl ends up calling that method once it inserts the line break.

Another way is to close the buffer. In doing so, it is normally forced to dump information that has not yet been sent to the output device.

Now, why has XCode stopped working? Technically it is not that it has stopped working but that its operation has been modified. What must happen before is that the IDE closed the output buffers before ending the program. That allowed you to see the message just before pressing a key and the console to close.

However, it looks like the program does not close these buffers until the program finishes physically. The effect is that even if the message is displayed by the console, the printing time is so ephemeral that it seems to the user that nothing has been shown. You can try running the program from a console opened by you and you will see how the message is displayed (or should be displayed).

    
answered by 05.04.2017 в 08:37
0

This was resolved in version 8.3.2. It's the fifth point

    
answered by 21.04.2017 в 01:12