C standard library corner case
问题 Is the following program a valid C program? #include <stdio.h> int main() { fwrite("x", 1, 1, stderr); fflush(stderr); fgetc(stderr); fwrite("y", 1, 1, stderr); return 0; } Notice that I try to read from stderr. When I compile it in Visual C++ 2008, and run it, I get the following output: xy which makes sense. However, when I redirect stderr to a file ( test.exe 2> foo.txt ), I get a "Debug Assertion Failed" window with the message: "Inconsistent Stream Count. Flush between consecutive read