Im working on a simple Console based Tic Tac Toe game, just for learning experience, and after i compiled and ran it it did something weird. (View screenshot)
The smiley looking characters at the end of each dashed line, is not located in my program, and I cannot see why it would appear.
Question
justin89h
Im working on a simple Console based Tic Tac Toe game, just for learning experience, and after i compiled and ran it it did something weird. (View screenshot)
The smiley looking characters at the end of each dashed line, is not located in my program, and I cannot see why it would appear.
#include <iostream> using namespace std; int main() { char thecmd[50]; int set[4][4], x, y; int turn = 1; char bigline[50]; strcpy(bigline, "------------------------------------------------------------"); for ( x=1; x<=3; x++ ) { for ( y=1; y<=3; y++ ) { set[x][y] = 0; } } while ( strcmp(thecmd,"exit") ) { if ( turn==1 ) { turn = 2; } else { turn = 1; } cout << "Command: "; cin.getline(thecmd,50); cout << "\n"; if ( !strcmp(thecmd,"go 1") ) { set[1][1] = turn; } if ( !strcmp(thecmd,"go 2") ) { set[1][2] = turn; } if ( !strcmp(thecmd,"go 3") ) { set[1][3] = turn; } if ( !strcmp(thecmd,"go 4") ) { set[2][1] = turn; } if ( !strcmp(thecmd,"go 5") ) { set[2][2] = turn; } if ( !strcmp(thecmd,"go 6") ) { set[2][3] = turn; } if ( !strcmp(thecmd,"go 7") ) { set[3][1] = turn; } if ( !strcmp(thecmd,"go 8") ) { set[3][2] = turn; } if ( !strcmp(thecmd,"go 9") ) { set[3][3] = turn; } for ( x=1; x<=3; x++ ) { for ( y=1; y<=3; y++ ) { cout << set[x][y]; } cout << "\n"; } cout << "\n" << bigline << endl; } return 0; }I am using Windows XP professional. I used Visual C++ v6.0 to compile it, and the source above, after recompiling, kept this weird error.
Does anyone know why this happens, or could they compile it if they use Visual c++, and tell if the same or similar error happens?
Link to comment
Share on other sites
4 answers to this question
Recommended Posts