I expect ReadConsoleW() to return after reading a specific number of bytes.
But it doesn't return.
How can I make ReadConsoleW() return as soon as it finished reading the number of bytes specified?
The code I tried is here:
#include <stdio.h>
#include <Windows.h>
int main()
{
//something is being written to stdin.
Sleep(2000);
int b;
int r;
//read 3 wide character
ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), &b, 3*sizeof(TCHAR), (LPDWORD)&r, NULL);
//problem: no returns until enter pressed
putc(b,stdout);
while(1)
{};
}
Use SetConsoleMode to turn off ENABLE_LINE_INPUT flag. No line editing will be available, but it won't wait until the Enter is pressed.
Note that you can't read three WCHARs into an int.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With