but new info. I know that I need a for loop to save the moves the user makes (tic tac toe for those of you who have no idea what im talking about). I have the entire program run out of a for loop that will end if it reaches 9 moves, but after each move the previous move is deleted from the memory. How do I make it stick in them memory? heres my source.
Code:
#include <iostream>
#include <string>
using namespace std;
void xturn();
void oturn();
void checkwin();
int board[9] = {0,1,2,3,4,5,6,7,8};
int playa[9] = {0,1,2,3,4,5,6,7,8};
int main()
{
int x, move, xx;
for (x=0; x<=8; x++)
{
if (playa[x] == 0 || playa[x] == 2 || playa[x] == 4 ||
playa[x] == 6 || playa[x] == 8)
{
cin >> move;
cout << "turn " << playa[x] << endl;
}
else
if (playa[x] == 1 || playa[x] ==3 || playa[x] == 5 ||
playa[x] == 7)
{
cout << "computer turn " << playa[x] << endl;
}
if (playa[x]==5)
{
cout << playa[0] << endl;
}
if (board[x] == 1 && board[x] == 2 && board[x] == 3)
{
cout << "WINNER!" << endl;
}
}
cout << "DRAW!!" << endl;
return 0;
}
void xturn()
{
int x, xx;
cin >> xx;
cout << "you move to square " << x << endl;
cout << playa[x] << endl;
}
void oturn()
{
int y;
cout << "computer not ready yet" << endl;
}