Thread: Tic-Tac-Toe errors

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176

    Tic-Tac-Toe errors

    I get lots of errors for this:
    Code:
    #include<iostream>
    #include<windows.h>
    #include<conio.h>
    #include<cstdlib>
    using namespace std;
    
    char a1=' ';
    char a2=' ';
    char a3=' ';
    char b1=' ';
    char b2=' ';
    char b3=' ';
    char c1=' ';
    char c2=' ';
    char c3=' ';
    
    
    bool Check();
    void DrawBoard();
    void DrawHelpBoard();
    
    int main(){
    	cout<<"Tic-Tac-Toe!\n";
    	int move;
    	char X_or_O;
    	char O_or_X;
    	int xo=rand()%2;
    	if(xo=0){
    		X_or_O='X';
    		O_or_X='O';
    		cout<<"You are X";
    	if(xo=1){
    		X_or_O='O';
    		O_or_X='X';
    		cout<<"You are O";
    		}
    	Sleep(2000);
    	while(Check())
    		clrscr();
    		DrawBoard();
    		DrawHelpBoard();
    		cin>>move;
    		if(move=1 && a1!=X_or_O){a1=X_or_O;}
    			else if(move==2 && a2!=X_or_O){a2=X_or_O;}
    			else if(move==3 && a3!=X_or_O){a3=X_or_O;}
    			else if(move==4 && b1!=X_or_O){b1=X_or_O;}
    			else if(move==5 && b2!=X_or_O){b2=X_or_O;}
    			else if(move==6 && b3!=X_or_O){b3=X_or_O;}
    			else if(move==7 && c1!=X_or_O){c1=X_or_O;}
    			else if(move==8 && c2!=X_or_O){c2=X_or_O;}
    			else if(move==9 && c3!=X_or_O){a1=X_or_O;}
    			else{
    				MessageBox(NULL, "Not a valid space", "ERROR", MB_OK);
    };
    }
    
    
    void DrawBoard(){
    	cout<<a1<<"|"<<a2<<"|"<<*a3<<"|\n------"<<b1<<"|"<<b2<<"|"<<b3<<"|\n------"<<c1<<"|"<<c2<<"|"<<c3<<"|\n\n";
    }
    void DrawHelpBoard(){
    	cout<<"1|2|3|\n------4|5|6|\n------7|8|9|";
    }
    bool Check(){
    	if (a1='X' && a2='X' && a3='X'){ return FALSE;}
    	else if (b1=='X' && b2='X' && b3='X'){ return FALSE;}
    	else if (c1=='X' && c2='X' && c3='X'){ return FALSE;}
    	else if (a1=='X' && b1='X' && c1='X'){ return FALSE;}
    	else if (a2=='X' && b2='X' && c2='X'){ return FALSE;}
    	else if (a3=='X' && b3='X' && c3='X'){ return FALSE;}
    	else if (a1=='X' && b2='X' && c3='X'){ return FALSE;}
    	else if (a3=='X' && b2='X' && c1='X'){ return FALSE;}
    
    	else if (a1=='O' && a2='O' && a3='O'){ return FALSE;}
    	else if (b1=='O' && b2='O' && b3='O'){ return FALSE;}
    	else if (c1=='O' && c2='O' && c3='O'){ return FALSE;}
    	else if (a1=='O' && b1='O' && c1='O'){ return FALSE;}
    	else if (a2=='O' && b2='O' && c2='O'){ return FALSE;}
    	else if (a3=='O' && b3='O' && c3='O'){ return FALSE;}
    	else if (a1=='O' && b2='O' && c3='O'){ return FALSE;}
    	else if (a3=='O' && b2='O' && c1='O'){ return FALSE;}
    	else{
    		return TRUE;
    };
    }
    Errors:
    Code:
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    tictactoe.cpp:
    Warning W8060 tictactoe.cpp 28: Possibly incorrect assignment in function main(
    
    Warning W8060 tictactoe.cpp 32: Possibly incorrect assignment in function main(
    
    Warning W8060 tictactoe.cpp 43: Possibly incorrect assignment in function main(
    
    Error E2141 tictactoe.cpp 58: Declaration syntax error in function main()
    Error E2139 tictactoe.cpp 85: Declaration missing ; in function main()
    Error E2134 tictactoe.cpp 85: Compound statement missing } in function main()
    Warning W8004 tictactoe.cpp 85: 'xo' is assigned a value that is never used in
    unction main()
    Warning W8004 tictactoe.cpp 85: 'O_or_X' is assigned a value that is never used
    in function main()
    *** 3 errors in Compile ***
    Edited code and posted errors
    Last edited by fuh; 06-19-2003 at 07:14 PM.
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me with my simple Tic tac toe prog
    By maybnxtseasn in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 06:25 PM
  2. Help with Tic Tac Toe game
    By snef73 in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2003, 08:33 AM
  3. my tic tac toe game, please try it
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 04-14-2002, 05:16 PM
  4. Tic Tac Toe Help
    By aresashura in forum C++ Programming
    Replies: 1
    Last Post: 11-21-2001, 12:52 PM
  5. Replies: 22
    Last Post: 11-08-2001, 11:01 PM