c++ - 如何从多个字符串变量中声明一个字符串 C++
问题描述
我想知道如何从多个字符串变量中声明一个字符串。
示例代码:
std::string one = "one1";
std::string two = "two2";
std::string three = "three3";
std::string OneTwoThree = (one, " ", two, " ", three); // Here I want to save it as "one1 two2 three3"
std::cout << OneTwoThree;
非常感谢任何帮助!
解决方案
您可以通过将所有三个字符串添加为
std::string OneTwoThree = one+" "+two+" "+three;
推荐阅读
- javascript - 问题在传单中加载离线 opesttreetmap
- c# - 使用c#在word文档中打开并查找字符串
- javascript - 如何使用两种不同的绑定字符串,如果一个被选中,则将另一个变为 false
- java - 如何从浮点数中获取 int 值?
- botframework - 是否有可能/计划将 PSTN 号码分配给团队机器人?
- ionic-framework - Ionic 3 从数据中选择列表
- java - 在 Java 中迭代 HashSet 的最佳方法
- java - 如何在@RequestParam 中路径任何值?
- dns - 使用 AWS ELB 将域名添加到 ECS 应用程序
- c - 如何在 Cygwin 中使用 gcc 使用“getcwd”获取完整的工作目录路径