Visual Studio C++ Error Link1120 [Duplicate]

I was writing a C++ program in visual studio 2013 and the program is very simple one and when I compile there was error this is third time I see this error. Here's the program:

#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;
}

...and here's the error:

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:\Users\Sorena\documents\visual studio 2013\Projects\Calculator_madeByMe\Debug\Calculator_madeByMe.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========>
2

Your compiling as a Windows application, which does not use the "int main()" signature when calling the entry point.

Switch to a console application in Project -> Properties -> Linker -> System -> SubSystem -> Console. There might be more involved than just this setting, so if it still doesn't compile, remake your project and make sure to choose Console Application.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest