简单方法: 添加头文件:#include <io.h> #include <fcntl.h> 添加代码:AllocConsole(); freopen("CONOUT$","w",stdout); freopen("CONIN$","r",stdin); 亲测有效。