谁能告诉我如何在C语言中显示一个可以打印变量的消息框?
我是说像这样。
#include <stdio.h>
#include <windows.h>
main()
{
int x = 5;
MessageBox(0, "Variable x is equal to %d", "Variable", 0);
/* Where do I specify the variable so that 5 will display?*/
getch();
}
就像这样
Variable
Variable x is equal to 5.
先谢谢你!
MessageBox
本身不支持 printf
像格式化。你必须使用 snprintf
为此。
char buf[1024];
snprintf(buf, 1024, "Variable x is equal to %d", x);
MessageBox(0, buf, "Variable", 0);