<分区>
最近我开发了一个程序,我必须在其中调用 system();
,它接受一个 const char*
。我需要在此调用中使用一个字符串数组。这是一些示例代码。
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
int main()
{
string stackoverflow[5] = {"a", "b", "c", "d", "e"};
int i = 0;
while(i <= 5)
{
system("wget -O" + stackoverflow[i] + "\"www.google.com\"");
i++;
}
}
旁注:我尝试使用 const char b = stackoverflow[i].c_str()
但出现错误:
expression must have integral or unscoped enum type
和
'+' cannot add two pointers
顺便说一句,我正在使用 Visual Studio。我不知道此时我应该做什么。
感谢阅读。我是新手,所以任何帮助将不胜感激。我希望有一个不需要将我的数组转换为 vector 的解决方案,因为我在这个项目中有很多代码,这将需要重组大量代码。 PS 抱歉我在 c+p 失败了缩进