只需要执行 freopen_s(&m_new_stdout_file,"CONOUT$","w+t",stdout); 不过别忘了程序结束时调用 fclose(m_new_stdout_file); 以免造成内存泄露。