Advertisement

Anyone who can help me to find errors?

Started by October 02, 2001 06:38 AM
0 comments, last by Michael.Van 23 years, 2 months ago
//Well,it crashes(or stopped?)when I input something shall be right; //It''s written in C++ but run under Windows(VC++); //THANKS; #include void matrix_initial(void); void matrix_show(void); void get_player1_move(void); void get_player2_move(void); char check(void); char matrix[3][3]; int check_draw(void); int draws; main() { char done='' ''; cout<<"Tic-Tac-Toe"<<"\n"; matrix_initial(); do { matrix_show(); get_player1_move(); done=check(); cout<<"Done:"<>i3>>j3; i3--;j3--; if (matrix[i3][j3]=='' '') { matrix[i3][j3]=''X''; } else { cout<<"\n"<<"Wrong Input"; get_player1_move(); } } void get_player2_move(void) { int i4,j4; cout<<"Player2''s corrider:"; cin>>i4>>j4; i4--;j4--; if (matrix[i4][j4]=='' '') { matrix[i4][j4]=''Y''; } else { cout<<"\n"<<"Wrong Input"; get_player2_move(); } } char check(void) { char check_matrix[3]; char check_matrix1[3]; int i=0; int j=0; for(i=0;i<3;i++) if(matrix[0]==matrix[1]&&matrix[0]==matrix[2]) return matrix[0]; for(i=0;i<3;i++) if (matrix[0]==matrix[1]&&matrix[0]==matrix[2]) return matrix[0]; for(i=j;i<3;j++) for(j=0;j<3;j++) { check_matrix=matrix[j]; check_matrix1=matrix[2-i][2-j]; } if (check_matrix[1]=check_matrix[2]=check_matrix[3]&&check_matrix[0]==''X'') return ''X''; if (check_matrix[1]=check_matrix[2]=check_matrix[3]&&check_matrix[0]==''Y'') return ''Y''; if (check_matrix1[1]=check_matrix1[2]=check_matrix1[3]&&check_matrix1[0]==''X'') return ''X''; if (check_matrix1[1]=check_matrix1[2]=check_matrix1[3]&&check_matrix1[0]==''Y'') return ''Y''; return '' ''; } int check_draw(void) { int a,b; for(a=0;a<3;a++) { for(b=0;b<3;b++) if(matrix<A href='http://<b>=='' '') break; if(matrix[a]=='' '') break; } if(a*b==9) draws=1; return draws; } </b> </i> ' Target=_Blank>Link</a>
You probably aren''t going to get any replies to this. Either put it up on a web server somewhere and post a link (At least it''d be legible that way) or run it through the debugger yourself. (Push F5 in MSVC. It''ll show you where the program crashed.) For further information read about the debugger in your Visual C__ manual.

This topic is closed to new replies.

Advertisement