system(string)

error C2664: 'system' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'

The error turns that. I'm not sure how to turn it to 'const char *'.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
	string Colors [] = {"color 0a","color 0b","color 0c","color 0d","color 0e","color 0f"};
	string ColorPick;
	bool Damn = false;

	while (Damn != true)
	{
		cout << rand() % 9;
		ColorPick = Colors [(rand() % 5)];
		system(ColorPick);
	}

	return 0;
}


Thank your for the help!
Last edited on
system(ColorPick.c_str());
Thank you,
Topic archived. No new replies allowed.