Compiler Help

I am somewhat of a beginner and I made a basic Tic Tac Toe game, I compared my code to that of the video I watched, and when I compile and run my code, it just says main and won't actually do anything.
#include <iostream>
using namespace std;
char matrix[3][3] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
char player = 'X';
void Draw()
{
system("cls");
cout << "Tic Tac Toe v1.0" << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << matrix[i][j] << " ";
}
cout << endl;
}
}
void Input()
{
int a;
cout << "Press the number of the field: ";
cin >> a;

if (a == 1)
matrix[0][0] = player;
else if (a == 2)
matrix[0][1] = player;
else if (a == 3)
matrix[0][2] = player;
else if (a == 4)
matrix[1][0] = player;
else if (a == 5)
matrix[1][1] = player;
else if (a == 6)
matrix[1][2] = player;
else if (a == 7)
matrix[2][0] = player;
else if (a == 8)
matrix[2][1] = player;
else if (a == 9)
matrix[2][2] = player;
}
void TogglePlayer()
{
if (player == 'X')
player = 'O';
else
player = 'X';
}
char Win()
{
//first player
if (matrix[0][0] == 'X' && matrix[0][1] == 'X' && matrix[0][2] == 'X')
return 'X';
if (matrix[1][0] == 'X' && matrix[1][1] == 'X' && matrix[1][2] == 'X')
return 'X';
if (matrix[2][0] == 'X' && matrix[2][1] == 'X' && matrix[2][2] == 'X')
return 'X';

if (matrix[0][0] == 'X' && matrix[1][0] == 'X' && matrix[2][0] == 'X')
return 'X';
if (matrix[0][1] == 'X' && matrix[1][1] == 'X' && matrix[2][1] == 'X')
return 'X';
if (matrix[0][2] == 'X' && matrix[1][2] == 'X' && matrix[2][2] == 'X')
return 'X';

if (matrix[0][0] == 'X' && matrix[1][1] == 'X' && matrix[2][2] == 'X')
return 'X';
if (matrix[2][0] == 'X' && matrix[1][1] == 'X' && matrix[0][2] == 'X')
return 'X';

//second player
if (matrix[0][0] == 'O' && matrix[0][1] == 'O' && matrix[0][2] == 'O')
return 'O';
if (matrix[1][0] == 'O' && matrix[1][1] == 'O' && matrix[1][2] == 'O')
return 'O';
if (matrix[2][0] == 'O' && matrix[2][1] == 'O' && matrix[2][2] == 'O')
return 'O';

if (matrix[0][0] == 'O' && matrix[1][0] == 'O' && matrix[2][0] == 'O')
return 'O';
if (matrix[0][1] == 'O' && matrix[1][1] == 'O' && matrix[2][1] == 'O')
return 'O';
if (matrix[0][2] == 'O' && matrix[1][2] == 'O' && matrix[2][2] == 'O')
return 'O';

if (matrix[0][0] == 'O' && matrix[1][1] == 'O' && matrix[2][2] == 'O')
return 'O';
if (matrix[2][0] == 'O' && matrix[1][1] == 'O' && matrix[0][2] == 'O')
return 'O';

return '/';
}
int main()
{
Draw();
while (1)
{
Input();
Draw();
if (Win() == 'X')
{
cout << "X wins!" << endl;
break;
}
else if (Win() == 'O')
{
cout << "O wins!" << endl;
break;
}
TogglePlayer();
}
system("pause");
return 0;
}

Thanks
Seems to run OK. Here's the result of inputting 1 2 5 6 9 at the command line, with the output redirected to file:
Tic Tac Toe v1.0
1 2 3 
4 5 6 
7 8 9 
Press the number of the field: Tic Tac Toe v1.0
X 2 3 
4 5 6 
7 8 9 
Press the number of the field: Tic Tac Toe v1.0
X O 3 
4 5 6 
7 8 9 
Press the number of the field: Tic Tac Toe v1.0
X O 3 
4 X 6 
7 8 9 
Press the number of the field: Tic Tac Toe v1.0
X O 3 
4 X O 
7 8 9 
Press the number of the field: Tic Tac Toe v1.0
X O 3 
4 X O 
7 8 X 
X wins!
Press any key to continue . . . 
What compiler did you use?
What compiler did you use?

g++ , from the Windows command line.

Your program won't spit out the word 'main'. I imagine whatever programming environment you are using is simply telling you which routine it is in (the one loaded at start-up happens to be called 'main'). Did you actually start it? There's nothing particularly wrong with the C++ code.
Topic archived. No new replies allowed.