undefined reference to 'Winmain@16' and ld returned l exit status

I am trying to run following code in Code blocks and getting errors 'undefined reference to Winmain@16' and 'ld returned l exit status' when I build it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  #include <iostream>
using namespace std;

bool accept3 ()
{
    int tries = 1;
    while (tries < 4) {
        cout << "Do you want to continue (y or n)? \n";
        char answer = 0;
        cin >> answer;
        switch (answer)
        {
        case 'y':
            return true;
        case 'n':
            return false;
        default:
            cout << "Sorry, I didn't get it! \n";
            tries = tries +1;
        }

    }
    cout << "I will take that for a no \n";
    return false;


}
Seems yo created a Windows app instead of a console app. One option is to copy your code, create a console app and paste it into main.cpp
Nope. I retried using console app but no luck. Other codes are working fine though.
Actually the problem is that your code doesn't have a main method.
The message about missing WinMain is just misleading.
Add a main method and it should work..
Last edited on
Oh yes, you are right! Got it now. Thanks! :-)
Topic archived. No new replies allowed.