-2

I want to create sth like:

int main ()
{
    string s{};
    
    std::cout << "Enter CMD: \n";
    
    getline(cin,s);
    
    system(s);
}

But since I can use only const char on system, its not working at all, is there any different solution to this? mabye shellexecute?

1 Answers1

1

You can use std::string::c_str().

system(s.c_str());
MikeCAT
  • 73,922
  • 11
  • 45
  • 70