This is a snippet of my code:
AttachConsole(-1);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin); //this doesn't seem to do anything
int n = 0;
cin >> n;
cout << n + 1;
FreeConsole();
WNDCLASSA MainWindow = { 0 };
MainWindow.hbrBackground = (HBRUSH) COLOR_WINDOW;
MainWindow.hCursor = LoadCursor(NULL, IDC_ARROW);
MainWindow.hInstance = hInst;
//here the window gets created etc.
Obviously the usage of the console here is basic, but that should do for this question. The problem is that functions like cin
or scanf
are not working. cout
, cerr
, clog
, printf
work fine, but the input functions don't do anything. How can I make stdin
work (preferrably with cin
)?