Hello! I create a console with this function:

void ConsoleClass::CreateConsole(char *consoleName) { int hConHandle = 0; FILE *fp; AllocConsole(); SetConsoleTitle(consoleName); m_Console = GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle(PtrToUlong(m_Console), 0); fp = _fdopen(hConHandle, "w"); *stdout = *fp; setvbuf(stdout, NULL, _IONBF, 0); } 

In the window, in the WndProc function, when I click on a button, I perform this function and write printf ("Hello% s \ n", buffer). The console is displayed, but no data is displayed.

  • why do you do all these manipulations with handles? Or somewhere else? I after SetConsoleTitle would output nothing more. - KoVadim 8:39 pm
  • If you do not write anything after SetConsoleTitle, then all the same printf will not work. m_Console = GetStdHandle (STD_OUTPUT_HANDLE); This is necessary for writing through the standard WriteConsole function, I send the handle there, and the rest is copied, it is not necessary in principle. write something to it, but through printf it is all done faster - helldrg
  • fp = _fdopen (hConHandle, "w"); * stdout = * fp; setvbuf (stdout, NULL, _IONBF, 0); This part is intended to redirect output to the console (unbuffered output) - helldrg

0