You are here

Implementation of the output method that writes into the console window

The methods WriteToConsole and WriteCharToConsole call the windows API method WriteConsole and reset the output buffer.

void OG_constreambuf::WriteToConsole()
{
  DWORD dwCharsToWrite = pptr() - pbase();
  DWORD dwCharsWritten;

  if (pbase() != pptr())
  {
    WriteConsole(hConsoleOut, pReserve, dwCharsToWrite,
      &dwCharsWritten, NULL);

    setp(pbase(), epptr());
  }
}

void OG_constreambuf::WriteCharToConsole(int c)
{

  DWORD dwCharsWritten;
  int c1 = c;
  WriteConsole(hConsoleOut, &c1, 1, &dwCharsWritten, NULL);
}