有没有win32编程因为打印变量调试程序而头疼呢.方法二的函数完全类似printf.非常完美.
方法一:

不带参数输出如printf("hello world");
OutputDebugString("debug");
 case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDS_BTN1:
OutputDebugString("1");
break;
case IDS_CLEAR:
SetWindowText(GetDlgItem(hWnd,IDS_EDIT),(LPCTSTR)"");
break;
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break; 

使用工具debug view查看:

方法二:

带参数输出入如 printf("hello %s welcome this %d\n", "world", "501");

 #include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <windows.h> void __cdecl odprintf(const char *format, ...)
{
char buf[], *p = buf;
va_list args; va_start(args, format);
p += _vsnprintf(p, sizeof buf - , format, args);
va_end(args); while ( p > buf && isspace(p[-]) )
{
*--p = '\0';
*p++ = '\r';
*p++ = '\n';*p = '\0';
}
OutputDebugString(buf);
} 

使用方法:

odprintf("Cannot open file %s [err=%ld]", "test.c", 110201);

编译运行之后使用方法一查看

win32程序调试OutputDebugString 类似printf格式化输出的更多相关文章

  1. C语言 printf格式化输出,参数详解

      有关输出对齐 int main(int argc, char* argv[]){ char insertTime[20] = {"1234567890"}; double in ...

  2. (Go)06. Printf格式化输出、Scanf格式化输入详解

    Print.Println .Printf .Sprintf .Fprintf都是fmt 包中的公共方法,在需要打印信息时需要用到这些函数,那么这些函数有什么区别呢? Print: 输出到控制台(不接 ...

  3. shell printf格式化输出语句

    printf 命令用于格式化输出, 是echo命令的增强版.它是C语言printf()库函数的一个有限的变形,并且在语法上有些不同. 注意:printf 由 POSIX 标准所定义,移植性要比 ech ...

  4. C printf格式化输出

    转载:https://blog.csdn.net/wucz122140729/article/details/98434702 格式化输出       格式化输出的函数有printf.sprintf和 ...

  5. win32调试工具原理OutputDebugString以及如何获取输出信息

    在应用程序和调试器之间传递数据是通过一个 4KB 大小的共享内存块完成的,并有一个互斥量和两个事件对象用来保护对他的访问.下面就是相关的四个内核对象: 对象名称 对象类型 DBWinMutex Mut ...

  6. printf 格式化输出符号详细说明(转)

    %a             浮点数.十六进制数字和p-记数法(C99)%A 浮点数.十六进制数字和p-记法(C99)%c 一个字符(char) %C           一个ISO宽字符 %d 有符 ...

  7. printf()格式化输出详解

    % - 0 m.n l或h 格式字符 下面对组成格式说明的各项加以说明: ①%:表示格式说明的起始符号,不可缺少. ②-:有-表示左对齐输出,如省略表示右对齐输出. ③0:有0表示指定空位填0,如省略 ...

  8. KEIL C51 printf格式化输出特殊用法

    作者:dragoniye   发布:2014-02-15 12:44   分类:硬件     抢沙发   /*******************************************KEI ...

  9. c语言 printf格式化输出

    #include <iostream> #include<stdio.h> #include <cstring> using namespace std; int ...

随机推荐

  1. js中的this指向

    1, 指向window 全局变量 alert(this) //返回 [object Window] 全局函数 function sayHello(){ alert(this); } sayHello( ...

  2. 用php逐行读取文件

    做个备份年纪大了,都不愿意自己思考了 $str = file_get_contents($tmpfilename);//获得内容 $arr = explode("\n",$str) ...

  3. 22. Generate Parentheses

    https://leetcode.com/problems/generate-parentheses/ 题目大意:给出n对小括号,求出括号匹配的情况,用列表存储并返回,例如:n=3时,答案应为: [ ...

  4. py2exe 生成带图标的单个文件实例

    随便拉了个学习时用的测试程序来做的实例,原程序如下: #Filename:for.py count=0 for i in range(1,100,2): count+=i else: print 't ...

  5. AlarmReceiver 与IntentService的使用

    1:GetSmsService.java public class GetSmsService extends IntentService{ private AlarmManager alarmMan ...

  6. css案例学习之div ul li a 实现导航效果

    效果 代码 <html> <head> <title>无需表格的菜单</title> <style> body{ background-co ...

  7. Unix/Linux环境C编程入门教程(33) 命令和鼠标管理用户和组

    Linux是一个多用户.多任务的实时操作系统,允许多人同时访问计算机, 并同时运行多个任务.UNIX系统具有稳定.高效.安全.方便.功能强大等诸多优点,自20世纪70年代开始便运行在许多大型和小型计算 ...

  8. 【转】理解 Android Build 系统----不错

    $ mmm -help用法:make [选项] [目标] ...选项: -b, -m 忽略兼容性. -B, --always-make Unconditionally make all targets ...

  9. Jquery时间快捷控件(Jtime)配置v1.0

    1.脚本代码行 /** * @title 时间工具类 * @note 本类一律违规验证返回false * @author {boonyachengdu@gmail.com} * @date 2013- ...

  10. POJ22230 Watchcow (欧拉回路)

    Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6477   Accepted: 2823   Specia ...