自己开console的方法,适用于在win32 非console程序里使用控制台

以下示范了如何在非console程序下打开控制台,个人认为比OutputDebugString更有用哦.

#include <stdio.h>

AllocConsole();//打开控制台

if ( freopen("CONOUT$", "w+t", stdout) )
{

      //控制台初始化成功

}

//////

printf("...");

//////

fclose(stdout);//关闭控制台

各个函数说明

      函数名: freopen

  功 能: 替换一个流

  用 法: FILE *freopen(char *filename, char *type, FILE *stream);

  位置:stdio.h

原文地址:https://www.cnblogs.com/aicro/p/1493848.html