C++致命错误LNK1120:1个未解析的外部

How*_*Gee 14 c++ program-entry-point visual-studio-2010 fatal-error

导致此错误的原因是什么?我google了它,我发现的前几个解决方案是库和主要功能有问题,但在我的问题中似乎都很好,我甚至重新输入了两个!可能是什么导致了这个?

这可能会有所帮助:

MSVCRTD.lib(crtexew.obj):错误LNK2019:函数_ _tmainCRTStartup中引用的未解析的外部符号WinMain @ 16

#include <iostream>
using namespace std;
int main()
{
    const double A = 15.0, 
                 B = 12.0, 
                 C = 9.0;
    double aTotal, bTotal, cTotal, total;
    int numSold;

    cout << "Enter The Number of Class A Tickets Sold: ";
    cin >> numSold;
    aTotal = numSold * A;

    cout << "Enter The Number of Class B Tickets Sold: ";
    cin >> numSold;
    bTotal = numSold * B;

    cout << "Enter The Number of Class C Tickets Sold: ";
    cin >> numSold;
    cTotal = numSold * C;

    total = aTotal + bTotal + cTotal;

    cout << "Income Generated" << endl;
    cout << "From Class A Seats $" << aTotal << endl;
    cout << "From Class B Seats $" << bTotal << endl;
    cout << "From Class C Seats $" << cTotal << endl;
    cout << "-----------------------" << endl;
    cout << "Total Income: " << total << endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Dra*_*kar 24

来自 msdn

创建项目时,您选择的应用程序类型错误.当被问及您的项目是控制台应用程序还是Windows应用程序或DLL或静态库时,您做错了选择了Windows应用程序(错误的选择).

返回,重新开始,转到文件 - >新建 - >项目 - > Win32控制台应用程序 - >命名您的应用程序 - >单击下一步 - >单击应用程序设置.

对于应用程序类型,请确保选择"控制台应用程序"(此步骤是至关重​​要的步骤).

Windows应用程序的主要部分称为WinMain,因为DLL称为DllMain,.NET应用程序称为Main(cli :: array ^),静态库没有main.仅在控制台应用程序中主要称为main


小智 12

我曾经犯过这个错误.

事实证明我已将程序命名为ProgramMame.ccp而不是ProgramName.CPP

容易做...

希望这可能有所帮助


Mah*_*ika 7

我的问题是 int Main() 而不是 int main()

祝好运