1

I'm trying to write a code in C++ that allows you to enter some text and it will open a website with the variable s_input appended to it. However, I get this error:

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

I get that error for the last line you see.

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);

I am new to C++ and this is more of a learning program.. So please show as many examples as possible! Thanks!

alexander7567
  • 665
  • 13
  • 35
  • You really mean `system` API? Use `ShellExecute`, `ShellExecuteEx` or `CreateProcess` – Ajay Jul 18 '12 at 07:58

1 Answers1

7

If s_input is a std::string (I'm betting it is):

system(s_input.c_str());

The function system takes a const char* as parameter, as the error message clearly states.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625