Hi, i've only been learning c++ for a couple days now, so im fairly new to it. :p. After I read the basic tutorials and got somewhat used to the c++ environment, I attempted to create a calculator and after trying to solve all of my errors, it became very tedious. I solved alot of the errors myself, which were minor mistakes, but I had no idea what was wrong when I got the error: LIBCD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
Debug/Calculator.exe : fatal error LNK1120: 1 unresolved externals. Any help would be highly appriciated! :D.

#include <iostream>

using namespace std;

int main()
{

    int x, y, z;
    char op;
    int cal(int x, int y, int& z, char op);

    cout << "Please enter your first number:  ";
    cin >> x;

        cout << "Please enter your second number:  ";
        cin >> y;

            cout << "Please enter the math operator that you would like to use (Eg. " << x << " ? " << y << ")";
            cin >> op;

        while ((op = '/') && (y == 0))
        {
            cout << "Error:  Cannot divide by zero." << endl;
            cout << "Please enter a legal math operator:  ";
            cin >> op;
        }

    cal(x, y, z, op);

                cout << x << op << y << " = " << z << endl;
                cin.get();

}

int cal(int x, int y, int& z, char op)
{

    if (op = '+')
    {
        z = x + y;
    }
        else
        {
            if (op = '-')
                z = x - y;
            else
            {
                if (op = '*')
                    z = x * y;
                else
                {
                    if (op = '/')
                        z = x / y;
                }
            }
        }
    

    return z;

}

When you create the project, create a Console Application, not a GUI Application.

Hi ,

I compiled the program in VC and didnt got any error. Its working fine.
Only one warning. Thts beacuse u have declared main as
"int main (void)" and the main was not returning anything. Just add one "return 0" and the warning will vanish.

i have the same problem

commented: If you've the same problem: Just read this thread ok? But don't make such a dumb remark !! -1

i have the same problem

You have the same solution.
Are you sure that it's a good idea to reanimate 3-years old thread?

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.