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
#include
#include
#include
#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');
}
No comments:
Post a Comment