c++ - 在消息框 C++ 中发布或显示多个字符串

标签 c++ string messagebox

我想在 C++ 中的消息框的不同行中显示多个字符串。 我希望它显示为:

Number of Words: 10
Number of Sentences: 5
Number of Digits: 2
Number of Upper Case Characters:5

我该怎么做? MessageBox( NULL, HERE,"CSE 3120 - 学期项目", MB_OK | MB_ICONEXCLAMATION);

而不是这里,所有这些字符串都应该去..我只是不知道如何显示它们,所有数字都存储在变量中。

有什么想法吗? 提前致谢,伙计们:)

最佳答案

试试这个...

Number of Words: 10
Number of Sentences: 5
Number of Digits: 2
Number of Upper Case Characters:5    

char text[128];
sprintf(text, "Number of Words: %d", noOfWords);
sprintf(text, "Number of Sentences: %d", noOfSentences);
sprintf(text, "Number of Digits: %d", noOfDigits);
sprintf(text, "Number of Upper Case: %d", noOfUCase);
MessageBox(NULL, text, "", MB_OK);

关于c++ - 在消息框 C++ 中发布或显示多个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20297013/

相关文章:

c++ - calloc 比 malloc 好吗?

c - 如何比较两个链表的字符串?

c - 如何(有效地)在 C 中实现多位 Char 变量

c# - 获取时间过程需要几秒钟才能完成?

c++ - 单击菜单未出现在屏幕上时显示 MessageBox

c++ - c++ 是否像奇怪的重复模板模式一样保证将祖母基类向下转换为孙子类?

c++ - 寻找指针的来源

c# - 用 C# 烦人的 Windows 消息框

c++ - 通过 C++ 代码使用 WEKA 的最简单方法是什么?

java - 比较 Windows 操作系统中具有共同结构但不完全相同的窗口标题