0

I have made a Tic Tac Toe game using c++.. And i want to add play again feature to it.. But there is a problem...

its basic structure is like this headers char martix[3][3]={'1','2','3','4','5','6'','7','8',9'}; for loop to display it like 123 456 789 there are some functions defined here int main() { while(Play=='y') { while(1) { Input(); draw(); know some statement to check if win or draw and display result; } now input feom user if want to play again(y/n); cin<<play; } retuen 0; } Now everything works fine but if user say 'y' to play again the matrix will still look like end of last game ex 0x0 x0x x0x now when user say 'y' to playagain i want it to look like 123 456 789 again but you cant reassign values to char array..... so how can i solve this problem... i searched on google but i failed to find any solution... Help will be appreciated

23rd Jan 2019, 6:48 PM
Teddy
Teddy - avatar
5 Respuestas
+ 4
You can reset your matrix like this: int counter = 0; do { matrix[counter/3][counter%3] = (char)counter+49; } while(++counter < 9);
23rd Jan 2019, 7:14 PM
Anna
Anna - avatar
23rd Jan 2019, 7:04 PM
Zen
Zen - avatar
+ 1
https://code.sololearn.com/c0VOrMNeXRdT/?ref=app
23rd Jan 2019, 7:30 PM
Teddy
Teddy - avatar
0
i will try this i guess it will work
23rd Jan 2019, 7:11 PM
Teddy
Teddy - avatar
0
guys i made this code to reassign values to char type array..it was damn easy i was doing this in ultra complex way.. i got this idea after seeing zen's and Anna's. code thank you guys for help......
23rd Jan 2019, 7:33 PM
Teddy
Teddy - avatar