Public paste
blub
By: Console | Date: Oct 25 2009 14:33 | Format: C++ | Expires: never | Size: 563 B | Hits: 889

  1. #include <windows.h>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <stdio.h>
  6. #include <io.h>                 /* _open_osfhandle */
  7. #include <fcntl.h>     /* for _O_TEXT and _O_BINARY */
  8.  
  9. void Console()
  10. {
  11.         int hCrtIn, hCrtOut;
  12.         FILE *conIn, *conOut;
  13.  
  14.         AllocConsole();
  15.         hCrtIn = _open_osfhandle ((intptr_t) GetStdHandle(STD_INPUT_HANDLE), _O_TEXT);
  16.         hCrtOut = _open_osfhandle ((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
  17.         conIn = _fdopen( hCrtIn, "r" );
  18.         conOut = _fdopen( hCrtOut, "w" );
  19.         *stdin = *conIn;
  20.         *stdout = *conOut;
  21. }