+ 1
c++ tic tac toe
The game crashes when the computer chooses a played position. https://code.sololearn.com/cv0HpuQki8lq/#cpp
2 Respostas
+ 6
That's because you always pick the same spot so it runs until memory is gone. Your srand(time(NULL)) line should be in main so it is called only once. Each time you call it, it restarts the random number sequence. Since the current time doesn't change for a whole second, you end up passing the same number most times, getting the same sequence.
Next time, link your code.
+ 4
for big if(i == value) like that, use switch cases (works only for integer-like types)
Instead of storing A, B, C, ... strings, store an array of string. With that, you can also change the switch with simply one if