The code is simple
#include <iostream> #include <unistd.h> using namespace std; int main() { for(int i = 0; i < 3; ++i) { cout << "1 "; cout.flush(); sleep(1); } }
in the .pro file
QT += core TARGET = ProjectName greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TEMPLATE = app
If the output goes to Qt Creator "application exit" (the default location for the source code), each "1" starts on a new line.
If I compile and execute a separate * .cpp file in an Ubuntu terminal using g ++, it works properly.
If I create a new project in Qt Creator and the output goes to the Qt Creator console (a new window with a black background), it works properly.
Well, why does cout.flush () call a new line in the first case?
c ++ flush cout qt-creator
Michael Atanov
source share