Easiest way to set them back is a probably simple for loop:
1 2 3
for (int i=0; i<9; i++)
Square[i] = i + '0'; // Add the value of ASCII zero to the index
how can i use an array (for example from 1 to 9) in an if statement?
Just use a subscript as you did in your assignment statements. Keep in mind that if you're representing the grid as 1-9 to the user, your subscripts are from 0-8.
1 2 3
if (Square[4] == 'X') // Check the middle square
{ // then do something
}
Note: You didn't show the type of Square. I'm assuming it's char.
to reset square, consider...
const char orig[9] = {'1','2','3'}; //you can fill in the rest of them yourself.
...
char square[9];
memcpy(square, orig, 9); //9 = sizeof(char) * # of items, 9*1 = 9
to reset it.
you could also make orig a c-string or string. if they were all strings, a simple = assignment operator would do all the work for you:
const string orig = "123456789";
string square = orig;
...
//reset with
square = orig; // good times
you can still access orig as if it were a char array:
orig[x] works just fine!