创建命令行窗口


#include <stdio.h>
#include <io.h>
#include <FCNTL.H>

AllocConsole(); //打开控制台窗口以显示调试信息
SetConsoleTitleA("Debug Win Output"); //设置标题
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); //获取控制台输出句柄
INT hCrt = _open_osfhandle((INT)hCon, _O_TEXT); //转化为C文件描述符
FILE * hf = _fdopen( hCrt, "w" ); //转化为C文件流
setvbuf( hf, NULL, _IONBF, 0); //无缓冲
*stdout = *hf;

printf("sdd");



visual studio 中的c++程序 可以使用函数OutputDebugString(TEXT("cccc\n"));来输出程序结果,现实在vs的output窗口中。

posted @ 2013-04-20 15:29  fff8965  阅读(358)  评论(0编辑  收藏  举报