错误LNK2019:未解析的外部符号_WinMain @ 16

时间:2014-03-03 07:33:40

标签: c++ lnk2019

我有一个程序分配到期,我无法弄清楚什么是错的。我是初学程序员,到目前为止只有C ++经验。我唯一的文件是source.cpp文件。

我有2个错误Visual Studio(VS Express 2012)正在给我我的代码 错误1错误LNK2019:函数_ _tmainCRTStartup中引用的未解析的外部符号 WinMain @ 16 错误2错误LNK1120:1个未解析的外部(第1行第1列)

我无法弄清楚出了什么问题,我四处搜寻,但我仍感到无能为力。这是我的代码

#include <iostream>
#include <string>

using namespace std;


struct SoccerTeam
{
    string name;
    int number, pointsScored;
};

int main()
{
    const int MAX_PLAYERS = 12;
    SoccerTeam playerList[MAX_PLAYERS];
    int totalScore = 0;

    // User input
    for (int i = 0; i < MAX_PLAYERS; i++)
    {
        // Name
        cout << "Enter player " << (i+1) << "'s name: ";
        getline (cin, playerList[i].name);

        // Number
        cout << "Enter " << playerList[i].name << "'s number: ";
        cin >> playerList[i].number;
        while (playerList[i].number < 0)
        {
            cout << "ERROR: You cannot have negative numbers!\n"
                << "Enter " << playerList[i].name << "'s number again: ";
            cin >> playerList[i].number;
        }

        cout << "Enter the number of points " << playerList[i].name << " scored: ";
        cin >> playerList[i].pointsScored;
        while (playerList[i].pointsScored < 0)
        {
            cout << "ERROR: You cannot have a negative score!\n"
                << "Enter the number of points " << playerList[i].number << " scored again: ";
            cin >> playerList[i].pointsScored;
        }

        totalScore = totalScore + playerList[i].pointsScored;
    }

    // Output
    for (int i = 0; i < MAX_PLAYERS; i++)
    {
        cout << "Name\tNumber\tScore" << playerList[i].name << "\t" << playerList[i].number << "\t" << playerList[i].pointsScored << endl;
    }

    cout << endl << "The team scored " << totalScore << " points total";

    return 0;
}

0 个答案:

没有答案