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.
#include <iostream>
usingnamespace 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':
returntrue;
case'n':
returnfalse;
default:
cout << "Sorry, I didn't get it! \n";
tries = tries +1;
}
}
cout << "I will take that for a no \n";
returnfalse;
}
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..