-1

p1_choice variable stores data correctly, but can't replicate\overwrite the ttt array.

I want to store the data gained from the user in p1_choice variable to ttt[0} array.

#include <iostream>
#include <cmath>

using namespace std;

//CREATING VARIABLES
string ttt[9] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
string p1_choice;
int p2_choice;
int gametime = 20;

int main()
{
    while (gametime < 21) {
        cout << endl;
        gametime++;
        cout << "::: " << ttt[0] << " :: " << ttt[1] << " :: " << ttt[2] << " :::" << endl;
        cout << "::: " << ttt[3] << " :: " << ttt[4] << " :: " << ttt[5] << " :::" << endl;
        cout << "::: " << ttt[6] << " :: " << ttt[7] << " :: " << ttt[8] << " :::" << endl;

        cout << "PLAYER 1 ENTER YOUR COICE HERE........";
        cin >> p1_choice;
        cout << p1_choice << endl;
        p1_choice = ttt[6];
        cout << "::: " << ttt[6]
    }

    return 0;
}
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

1

If you want to overwrite a variable you have to use the assign operator this way: var_to_overwrite = new_value;

You did the opposite in your code.