-2

I am getting two errors:

Error 3 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

and:

Error 4 error LNK1120: 1 unresolved externals

Since I can not get the program to run, I am also unsure if Case 'A' will generate a roll or not. I don't want to display the results in Case 'A' and my gut feeling is scanf should not be there but I could be wrong.

Here is my code:

#include<stdlib.h>
#include<stdio.h>
#include <time.h>
#include <ctype.h>

#define PAUSE system("pause")


int main ()
{
    int diceOne, diceTwo, diceThree;
    int currentDiceSum=0, totalDiceSum=0;
    char choice;
    int count = 0;

    srand((unsigned)time(NULL));

    diceOne      =rand()%6+1;
    diceTwo      =rand()%6+1;
    diceThree    =rand()%6+1;

    do {
        printf("\n Roll the dice, but you only get 5 rolls! You can't play forever, you know. \n");

        printf("Main Menu\n");
        printf("A.Roll the Dice\n");
        printf("B.Display the Result of Last Roll\n");
        printf("C.Quit\n");

        printf("Enter your choice:   ");
        scanf(" %c", &choice);

        choice = toupper(choice);

        switch(choice) {
            case 'A': 
                printf("Dice are rolled!'\n");

                diceOne      =rand()%6+1;
                diceTwo      =rand()%6+1;
                diceThree    =rand()%6+1;


                count ++;
                break;
            case 'B':  
                if (count = 0) {
                    printf("Please roll the dice atleast once\n");
                }  else {
                    printf("Dice 1: %d\n", diceOne);
                    printf("Dice 2: %d\n", diceTwo);
                    printf("Dice 2: %d\n", diceThree);

                    currentDiceSum = diceOne + diceTwo + diceThree;
                    printf("Dice Total: %d\n", currentDiceSum);
                    totalDiceSum+= currentDiceSum;
                }
                break;
            case 'C':
                if (count == 5)  
                    printf("Number of rolls: %d\n", count);

                printf("Total of all dice for all rolls:%d\n",totalDiceSum);
                printf("Goodbye, hope to see you again!!!\n");
                PAUSE;
                break;

            default:
                printf("Was not a valid menu choice (Please enter A,B,C\n");
                break;
        }
    } while (choice!= 'C'); 
}
double-beep
  • 5,031
  • 17
  • 33
  • 41

1 Answers1

0

Error 3 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

This is linker error message.

I think you have created a GUI windows application as it requires WinMain as entry point.

You should change subsystem to console in linker settings.

If you are using Visual Studio then go to

Project properties then c\c++ then linker ->system-> Subsystem :CONSOLE(/SUBSYSTEM CONSOLE)

For code blocks -

Go to the Project then Properties. Under the Build targets tab,see combo box Type. For the Debug target, set it "Console application"

Plus your program works fine .It dosen't have any additional errors and also it does not crash.

ameyCU
  • 16,489
  • 2
  • 26
  • 41