使用聚合对象预期的' ... '进行初始化

initialization with ' ... ' expected for aggregate object

本文关键字:初始化 对象      更新时间:2023-10-16

我正试图用C++编写一个代码,允许您输入一些文本,它将打开一个附加变量s_input的网站。然而,我收到了这个错误:

"system":无法将参数1从"std::string"转换为"const"字符*'

我得到了你看到的最后一行的错误。

cin >> s_input;
transform(s_input.begin(), s_input.end(), s_input.begin(), tolower);
s_input = "start http://website.com/" + s_input + "/0/7/0";
system(s_input);

我是C++的新手,这更像是一个学习程序。。所以请展示尽可能多的例子!谢谢

如果s_inputstd::string(我打赌是):

system(s_input.c_str());

函数system采用const char*作为参数,正如错误消息明确指出的那样。