C++ run a string in system(); ???

October 19, 2011 at 12:43:18
Specs: Windows XP
My question is: how can I get system(); to run on a string? Here is my code:

#include <iostream>
#include <cstring>
#include <conio.h>
using namespace std;

int main() {
string en;
cout << "EXEName> ";
cin >> en;
system("taskkill /im" + en + "/f"); //Is this possible?
return 0;

How can I? (console)

See More: C++ run a string in system(); ???

Report •

October 20, 2011 at 10:29:18
If you're using C++ (and you are), use std::string, and build your command that way. Then call the c_str() when making your system() call.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question