【发布时间】:2013-02-04 04:54:06
【问题描述】:
我希望ReadConsoleW() 在读取特定数量的字节后返回。
但它不会返回。
如何让ReadConsoleW() 在完成读取指定的字节数后立即返回?
我试过的代码在这里:
#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)
{};
}
【问题讨论】:
标签: c windows console nonblocking