exactly as it says, there's no version of system()
that understands std::string
and std::string
can't be freely converted to const char *
(which system()
does understand), because std::string
may go away in ways that don't make sense in the general case.
you can explicitly convert from std::string
to const char *
easily, though: with std::string::c_str
, write your last line as
system(a.c_str());
Be aware that the returned const char *
's lifetime is tied to the string
it came from, once it goes out of scope, the pointer becomes invalid. This case is a fine time to use it, though, since system()
won't "hold on" to the pointer past its own return.