Please help

what is wrong with my code

I am getting these errors

Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
Error 2 error LNK1120: 1 unresolved externals

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <string>
using namespace std;

bool die( const string & msg );


int main(){
    cout <<"Choices:" <<endl;
    cout <<"A Astronomy" <<endl;
    cout <<"B Biology" <<endl;
    cout <<"C Computer Programming" << endl;
    cout <<"H History" <<endl;
    cout <<"input a letter to designate your choice: ";
    char choice;
    cin >>choice;
    if( !cin )  die( "input failure" );
    if( 'a' <= choice && choice <= 'z' )
        choice += 'A' - 'a';
    // switch conditional (choice) must be fixed-point type
    switch( choice ){
      // case label must be fixed-point constant
      case 'A':
        cout <<"The mass of the sun is 2 * 10^30 kilograms" <<endl;
        break;
      case 'B':
        cout <<"Life is impossible without ribosomes" <<endl;
        break;
      case 'C':
        cout <<"The halting problem has been proved impossible" <<endl;
        break;
      case 'H':
        cout <<"The Articles of Confederation were considerably less "
               "successful than the constitution" <<endl;
        break;
      default:
        cout <<"Sorry, that doesn't match any of the subjects I know" <<endl;
    }

} // main


bool die( const string & msg ){
    cout <<endl <<"Fatal error: " <<msg <<endl;
    exit( EXIT_FAILURE );
} // die 

The code compiles without error (Microsoft visual 2013 express).
It probably has to do with the fact that you selected to create a win32 project instead of a console project. You can change the subsystem properties of your project.
Topic archived. No new replies allowed.