hi im making tic tac toe and i have ran into a problem. after the space is set i want to put in the code for the computer generating a random number. if the space isnt filled it will set the string to O(the computer). but how do i make it do this?
Do you know how to use random numbers in C++? If not look up srand() and rand() in this website's library reference.
Anyway, what string are you setting to O and where is it? (I'd suggest that you construct the string based on what you randomized.)
yes i know how to use random numbers.(sorry made this post in school so i was rushed) im am trying to say if i hit one then in the if(spacefill1 == 0) (which means the space is empty), after the 2 statements the computer makes a random number. i want to make it so if the number that it picks(1-9) is taken up then it goes to another space and checks it until it finds a empty space.
After that you can generate a random number between 0 and 8 inclusive (remember array indexing starts at 0), and if it's occupied already then choose an other one somehow.