system read error

Hi, i want to cin a value for a for the system but it give me a lot of errors.
Code:

#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;
string a;

int main(void)
{
cin >> a;
system("start "<<a " "); //Its about a link
return 0;
}

//So, whats wrong?, and the "code" button is not working/idk how to use it
//Thanks in advance
Last edited on
Line 11: system() takes a const char *. What you're trying to pass is not legal.

You could use a stringstream:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
#include <stdlib.h>
#include <sstream>

using namespace std;
string a;

int main(void)
{   stringstream    ss;

    cin >> a;
    ss << "open " << a << " ";
    system (ss.str().c_str()); 
    return 0;
}


and the "code" button is not working/idk how to use it

http://www.cplusplus.com/articles/jEywvCM9/


Topic archived. No new replies allowed.