I’m using Microsoft Visual C++ 2008
I want to join some strings, and then use it with “system” command.
I tried to do it like this:
System::String^ link;
link = "wget.exe --output-document=log http://ADDRESS";
link = link + System::String::Copy(textBox_login->Text);
link = link + "&passwd=";
link = link + System::String::Copy(textBox_passwd->Text);
system(link); //LINE WITH ERROR
But i get error C2664: ‘system’ : cannot convert parameter 1 from ‘System::String ^’ to ‘const char *’
I appreciate any help 😉
Take a look at this question and this question.
In essence, the problem is that the
systemfunction expects a variable of the typeconst char*rather thanSystem::String.So you need to convert the string to a const char* (Using code from this answer) and use that as an argument for the system function.