Win32 Project, Empty Project.

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\Game\Debug\Game.exe : fatal error LNK1120: 1 unresolved externals

This doesn't have anything to do with the code. It looks like you created the wrong type of project. You can create a new project, click "Win32 Console Application" as the project type, then unclick the "Precompiled headers" box and click the "Empty Project" box. Add a C++ file file to the empty project, paste in the code above, delete that first int main() line, and compile the project.

Ahhhh thank you so much, it worked

Yes Vernon the code does work for me, thank you. I do have one more code problem though.
I want to make a two player tic tac toe game, but whenever I put

if (board[0][0] = 'X' && board[1][1] = 'X' && board[2][2] = 'X')
     {
                     gameOver();
     }

It says: 93 non-lvalue in assignment
and it says that for all of them.
Heres the code

#include<iostream>
using namespace std;

      char board[3][3];
      void displayBoard();
      int gameOver();
      int gameOver2();
      void saveGame();
      void resumeGame();
      void getPlayerMove();
      void getPlayer2move();
      char choice;

int main()
{
      board[0][0] = '1';
      board[0][1] = '2';
      board[0][2] = '3';
      board[1][0] = '4';
      board[1][1] = '5';
      board[1][2] = '6';
      board[2][0] = '7';
      board[2][1] = '8';
      board[2][2] = '9';
      
      cout << "Hello, welcome to tic-tac-toe." << endl;
      cout << "Would you like to resume your old game? (Y or N)" << endl;
      cin >> choice;
      
      if (choice == 'y' || choice == 'Y')
      {
                   resumeGame();
      }
      
      if (choice != 'y' || choice != 'Y')
      {      
            displayBoard();
            cout << "Press S to save, E to enter move, Q to quit." << endl;
            cin >> choice;
            
            if (choice == 's' || choice == 'S')
            {
                       saveGame();
            }
            
            else if (choice == 'e' || choice == 'E')
            {
                 getPlayerMove();
                 if (!gameOver())
                 {
                                 getPlayer2move();
                 }
                 
                 else if (choice == 'q' || choice == 'Q')
                 {
                      cout << "Thanks for playing." << endl;
                      return 0;
                 }
            }
      }
      
      return 0;      
}

void displayBoard()
{
     cout << endl;
     for (int i = 0; i < 3; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             cout << board[i][j];
             if (j < 2)
                cout << '|';
             else
                 cout << endl;
         }
         if (i < 2)
            cout << "-----";
            cout << endl;
     }
     
     cout << endl;
}

void getPlayerMove()
{
     system("CLS");
     if (board[0][0] = 'O' && board[1][1] = 'O' && board[2][2] = 'O')
     {
                     gameOver2();
     }
     if (board[0][0] = 'O' && board[0][1] = 'O' && board[0][2] = 'O')
     {
                     gameOver2();
     }
     if (board[0][0] = 'O' && board[1][0] = 'O' && board[2][0] = 'O')
     {
                     gameOver2();
     }
     if (board[0][1] = 'O' && board[1][1] = 'O' && board[2][1] = 'O')
     {
                     gameOver2();
     }
     if (board[2][0] = 'O' && board[1][1] = 'O' && board[0][2] = 'O')
     {
                     gameOver2();
     }
     if (board[0][2] = 'O' && board[1][2] = 'O' && board[2][2] = 'O')
     {
                     gameOver2();
     }
     if (board[1][0] = 'O' && board[1][1] = 'O' && board[1][2] = 'O')
     {
                     gameOver2();
     }
     if (board[2][0] = 'O' && board[2][1] = 'O' && board[2][2] = 'O')
     {
                     gameOver2();
     }
     displayBoard();
     cout << "Player 1: Enter a number or letter to place your move." << endl;
     cin >> choice;
     
     switch (choice)
     {
            case '1':
                 board[0][0] = 'X';
                 break;
            case '2':
                 board[0][1] = 'X';
                 break;
            case '3':
                 board[0][2] = 'X';
                 break;
            case '4':
                 board[1][0] = 'X';
                 break;
            case '5':
                 board[1][1] = 'X';
                 break;
            case '6':
                 board[1][2] = 'X';
                 break;
            case '7':
                 board[2][0] = 'X';
                 break;
            case '8':
                 board[2][1] = 'X';
                 break;
            case '9':
                 board[2][2] = 'X';
                 break;
     }
     getPlayer2move();
     return;
}
void getPlayer2move()
{
     system("CLS");
          if (board[0][0] = 'X' && board[1][1] = 'X' && board[2][2] = 'X')
     {
                     gameOver();
     }
     if (board[0][0] = 'X' && board[0][1] = 'X' && board[0][2] = 'X')
     {
                     gameOver();
     }
     if (board[0][0] = 'X' && board[1][0] = 'X' && board[2][0] = 'X')
     {
                     gameOver();
     }
     if (board[0][1] = 'X' && board[1][1] = 'X' && board[2][1] = 'X')
     {
                     gameOver();
     }
     if (board[2][0] = 'X' && board[1][1] = 'X' && board[0][2] = 'X')
     {
                     gameOver();
     }
     if (board[0][2] = 'X' && board[1][2] = 'X' && board[2][2] = 'X')
     {
                     gameOver();
     }
     if (board[1][0] = 'X' && board[1][1] = 'X' && board[1][2] = 'X')
     {
                     gameOver();
     }
     if (board[2][0] = 'X' && board[2][1] = 'X' && board[2][2] = 'X')
     {
                     gameOver();
     }
     displayBoard();
     cout << "Player 2: Enter a number or letter to place your move." << endl;
     cin >> choice;
     
     switch (choice)
     {
            case '1':
                 board[0][0] = 'O';
                 break;
            case '2':
                 board[0][1] = 'O';
                 break;
            case '3':
                 board[0][2] = 'O';
                 break;
            case '4':
                 board[1][0] = 'O';
                 break;
            case '5':
                 board[1][1] = 'O';
                 break;
            case '6':
                 board[1][2] = 'O';
                 break;
            case '7':
                 board[2][0] = 'O';
                 break;
            case '8':
                 board[2][1] = 'O';
                 break;
            case '9':
                 board[2][2] = 'O';
                 break;
     }
     getPlayerMove();
     return;
}

int gameOver()
{
    system("CLS");
    cout << "Good Job Player 1. You Won!!" << endl;
    system("PAUSE");
    return 0;
}

int gameOver2()
{
    system("CLS");
    cout << "Good Job Player 2. You Won!!" << endl;
    system("PAUSE");
    return 0;
}

void saveGame()
{
          return;
}

void resumeGame()
{
     return;
}

Remember, = is a assign operator while == is an equal operator. I give you 2 examples so that it might give you more idea.

Example 1:

int a = 5;  // you assign variable a with value 5.
if (a = 2) // and now you assign varaible a with value 2, since all the non-zero value are consider as true so the condition is true
   std::cout << a; // the output is 2

Example 2:

int a = 5 // assign variable a with value 5.
if (a == 2) // compare whether a equal to 2 or not. It is not true since 5 is not equal to 2
   std::cout << a; // will not be displayed because the condition is false
else
   std::cout << a; // the output is 5

Ah i dont understand im going to learn more C++

Ah i dont understand im going to learn more C++

LearnCPP, this site has a good free C++ tutorial. Totally recommended.

ok thank you, iv been using cplusplus, but i will use LearnCPP ^^

Thank you, it worked invisal. I know to use it, I just made a mistake. Now I have a different problem. With that same code, can you tell me why when someone wins, It does not exit. I used return 0; but it still wont exit.
Thank you.

Thank you, it worked invisal. I know to use it, I just made a mistake. Now I have a different problem. With that same code, can you tell me why when someone wins, It does not exit. I used return 0; but it still wont exit.
Thank you.

To exit the program, you need to return exitcode to the operator system simliarly to the returning value to main() function. The reason that return 0; in your gameOver() function doesn't work because it only end the gameOver() . To exit the program, you can use exit() function. For more information, check here.

Thank you again invisal. I havn't known that before. I thought it was just return 0; . Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.