Hello I am working on a tic-tac-toe project on my own. I am not taking a programming class so its not homework.
I have written pretty much the rest of the code and am now working on the AI.
For the AI i am going to have it take a copy of the (2 dimensional array) and it check if it can win in a move, then if the player can, then if it can in 2 moves, then the player and so on, there are some other things i will include. So in order to do this i think i need to pass a copy of the array, but i am not sure how to copy an array. So that is basically my question, how do you copy an array?
You can wrap the array into a class, in which case it’ll be copied automatically by the default-generated copy constructor and assignment operator:
Or do it manually:
Now you can copy it at will: