2012-07-17 63 views
1

我想用C++编写一个代码,允许你输入一些文本,它将打开一个网站,其变量s_input附加到它。然而,我得到这个错误:用'...'初始化集合对象的期望

'system' : cannot convert parameter 1 from 'std::string' to 'const char *'

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

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++,这是一个更多的学习程序..所以请尽可能多的示例!谢谢!

+0

你真的认为'system' API?使用'ShellExecute','ShellExecuteEx'或'CreateProcess' – Ajay 2012-07-18 07:58:36

回答

7

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

system(s_input.c_str()); 

函数systemconst char*作为参数,作为错误信息中明确指出。

+0

是的..那么做!谢谢! – alexander7567 2012-07-17 22:19:26