AllocConsole();
FILE* m_new_stdout_file=NULL;
freopen_s(&m_new_stdout_file, "CONOUT$", "w+t", stdout);
FILE* m_new_stdout_file=NULL;
freopen_s(&m_new_stdout_file, "CONOUT$", "w+t", stdout);
cout << ">>>to MFC Debuge " << endl;
添加此代码:控制台输出 >>>to MFC Debuge
用完记得关闭 fclose(m_new_stdout_file);
本文介绍了一种在C++中将标准输出重定向到控制台的方法,通过使用AllocConsole()函数创建控制台窗口,并利用freopen_s配合FILE*指针实现标准输出流(stdout)的重定向,最后通过实例演示了如何输出自定义字符串。
1605

被折叠的 条评论
为什么被折叠?



