在GUI程序中使用printf函数:

#include <io.h>  
#include <fcntl.h>  
  
void InitConsole()  
{  
    int nRet= 0;  
    FILE* fp;  
    AllocConsole();  
    nRet= _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);  
    fp = _fdopen(nRet, "w");  
    *stdout = *fp;  
    setvbuf(stdout, NULL, _IONBF, 0);  
}  

只要将上面的函数加到初始化的地方之后,就可以使用printf输出数据到console了,当然也可以使用cout输出。

参考:http://blog.csdn.net/visualeleven/article/details/5517541

相关文章:

  • 2021-05-08
  • 2021-11-17
  • 2022-12-23
  • 2021-11-27
  • 2021-12-17
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案