gpt4 book ai didi

c++ - 从一个函数返回多个字符串

转载 作者:行者123 更新时间:2023-11-30 00:57:04 24 4
gpt4 key购买 nike

我有一个函数,我希望能够返回打印出来的内容,这样我就可以在页面上打印输出。我将如何返回在这两个 if 语句中输出的两个字符串?

 std::vector<std::string> el;
split(el,message,boost::is_any_of("\n"));
std::string a ("");

for(int i = 0; i < el.size(); i++)
{
if(el[i].substr(0,3) == ".X/")
{
DCS_LOG_DEBUG("--------------- Validating .X/ ---------------")
std::string str = el[i].substr(3);
std::vector<std::string>st;
split(st,str,boost::is_any_of("/"));
boost::regex const string_matcher(splitMask[0]);
if(boost::regex_match(st[0],string_matcher))
{
a = "Correct Security Instruction";

}
else
{
a = "Incorrect Security Instruction"
}

boost::regex const string_matcher1(splitMask[1]);
if(boost::regex_match(st[1],string_matcher1))
{
a = "Correct Security screening result"
}
else
{
a = "Incorrect Security screening result"
}


return a;

}

}

感谢任何帮助:)

最佳答案

例如,您可以返回字符串的 std::pair

关于c++ - 从一个函数返回多个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9130107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com