When I try to make integers using the rand() function, I cannot include them in a string. These are the two codes that I have tried:
int x1, x2;
x1 = (rand() % 14 + 2);
x2 = (rand() % 14 + 2);
char c1 = char(x1);
char c2 = char(x2);
string Hand = {c1, c2};
cout << Hand << endl;
I don't get any errors with this one, but it doesn't run. This is the one I thought would be correct:
int c1, c2;
c1 = (rand() % 14 + 2);
c2 = (rand() % 14 + 2);
to_string(c1);
to_string(c2);
string Hand = {c1[0], c2[0]};
cout << Hand << endl;
Yet it isn't. This must be really simple. How is it done?