how to view printf output in win32 app on visual studio 2010?
来源:互联网 发布:MySQL删除重复记录 编辑:程序博客网 时间:2024/04/30 11:24
#include <windows.h>#include <stdio.h>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow){ int number = 10; char str[256]; sprintf_s(str, "It works! - number: %d \n", number); OutputDebugString(str); return 0;}
void SetStdOutToNewConsole(){ int hConHandle; long lStdHandle; FILE *fp; // allocate a console for this app AllocConsole(); // redirect unbuffered STDOUT to the console lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); fp = _fdopen( hConHandle, "w" ); *stdout = *fp; setvbuf( stdout, NULL, _IONBF, 0 );}
http://stackoverflow.com/questions/3009042/how-to-view-printf-output-in-win32-app-on-visual-studio-2010void SetStdOutToNewConsole(){ // allocate a console for this app AllocConsole(); // redirect unbuffered STDOUT to the console HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT); FILE *fp = _fdopen( fileDescriptor, "w" ); *stdout = *fp; setvbuf( stdout, NULL, _IONBF, 0 ); // give the console window a nicer title SetConsoleTitle(L"Debug Output"); // give the console window a bigger buffer size CONSOLE_SCREEN_BUFFER_INFO csbi; if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) ) { COORD bufferSize; bufferSize.X = csbi.dwSize.X; bufferSize.Y = 9999; SetConsoleScreenBufferSize(consoleHandle, bufferSize); }}
- how to view printf output in win32 app on visual studio 2010?
- How to embed Lua in C++ on Visual Studio
- How to build mex file directly in Visual Studio 2010?
- How to use Boost in Visual Studio 2010
- How To Set Dark Theme in Visual Studio 2010
- How to compile PortAudio in Visual Studio
- [c#] where to see console.write output in visual studio?
- Use printf to output stream on STM32F4
- How To Install Visual Studio Code On Ubuntu
- (ZT) how to view Visual Studio environmental variables
- how to modify Visual Studio 2010 environment
- How to debug a Visual Studio .NET 2005 Add-In
- How to disable Intellisense in Visual Studio 2008?
- How to create custom shortcut in visual studio
- How to change the default browser in Visual Studio
- How to create custom snippet in Visual studio
- how to output quotes in bash prompt
- How to output the message when using the function 'printf'
- Linux 的基础命令操作图解
- Android一个工程引用另一个工程
- Costing Methods
- 互联网上的常用端口
- 宁波工程学院[1372] Do What n个数中取出某些数使得和大于T且和最小
- how to view printf output in win32 app on visual studio 2010?
- hdu3343
- 使用Spread.NET创建Y Plot图表
- android应用安全——组件通信安全(Intent)
- jQuery实现ajax
- web开发平台的演变
- spring map使用annotation泛型注入问题分析
- android开机速度优化 | 全志A10
- 访问共享时输入的密码怎样保存与更改