How to get size of data available thru stdin with C++ [duplicate]
问题 This question already has answers here : WinAPI C++ client detect write on anonymous pipe before reading (3 answers) Closed 6 years ago . If I get a handle to stdin from a console app like so: HANDLE hStdIn = ::GetStdHandle(STD_INPUT_HANDLE); I can then read data from it: BYTE buff[32]; DWORD dwcbRead = 0; BOOL bReadRes = ::ReadFile(hStdIn, buff, SIZEOF(buff), &dwcbRead, NULL); My question is, how do I know how many bytes are available before I read them? PS. ReadFile seems to block if there