visual studio c++ error link1120

visual studio c++ error link1120

本文关键字:link1120 error c++ studio visual      更新时间:2023-10-16

我在visual studio 2013中编写了一个c++程序程序是非常简单的一个,当我编译有错误这是我第三次看到这个错误了。程序如下:

#include <iostream>
using namespace std;
int main()
{
    int x, y, z = 0;
    char c;
    bool quit = true;
    while (quit == true)
    {
        cout << "enter a number : ";
        cin >> x;
        cout << "enter a sign : ";
        cin >> c;
        cout << "enter another number : ";
        cin >> y;
        if (c == '+')
            z = x + y;
        if (c == '-')
            z = x - y;
        if (c == '*')
            z = x * y;
        if (c == '/' && y != 0)
            z = x / y;
        if (c == 'q')
            quit = false;
        cout << "Answer is : " << z << endl;
    }
    return 0;
}

…这里是错误:

1>------ Build started: Project: Calculator_madeByMe, Configuration: Debug Win32 ------
1>  Source.cpp
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:UsersSorenadocumentsvisual studio 2013ProjectsCalculator_madeByMeDebugCalculator_madeByMe.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========>

作为Windows应用程序编译,它在调用入口点时不使用"int main()"签名。

在项目->属性->链接器->系统->子系统->控制台中切换到控制台应用程序。可能会涉及到比这个设置更多的东西,所以如果它仍然不能编译,重做你的项目,并确保选择Console Application。

相关文章: