ok...i'm having trouble changing a value in a array into a character

void gameon(int **game,int &size,int &x,int &y,int &score1,int &score2)
{
   int i,j,num1,num2;
   cout<<"Please enter a number from the selected row/column -->";
   cin>>num1;
     for(j=0;j<size;j++)
     {
        if(num1==game[x][j])
        {
          cout<<"Number found"<<endl;
          game[x][j]=='X';
          score1=score1+num1;
          y=j;
        }
     }
     display(game,size,score1,score2);
}

i can't seem to change that specific number into 'X'..
can u guys help me out...

Two problems in one statement.

game[x][j]=='X';

First, you're using the equality test ( == ) instead of assignment ( = ).
Second, you're trying to assign a character to an integer variable. This will work (when you fix problem 1) but will not give you the result I think you're expecting. What will be assigned to the array element is the ASCII value of 'X' (which is 88, if I read my ASCII chart right.)

If you want to mark the spot as used or free or whatever, you'll need to pick a value out of the range of allowable values. For instance, if the valid data can be any positive number greater than 0 (zero), use 0. If 0 could be a valid data item, how about some negative number? If all possible numbers are potentially valid, then you need some other way to indicate the cell is empty/available or whatever. Perhaps a parallel array where you simply mark 0 or 1 to indicate that the corresponding cell in the data array is available or not.

This article has been dead for over six months. Start a new discussion instead.