Hello World
I am new to C, and I am very confused with what is going on in my program. I am sure that people have asked this before, but I am looking around and can't find anything on how to fix it. Any thoughts? Thanks!
Code:
// store starting variables
char buffer[2];
int numPlayers;
// print title
printf("*------------------------------------*\n");
printf("| |\n");
printf("| Wheel |\n");
printf("| of |\n");
printf("| Fortune |\n");
printf("| |\n");
printf("*------------------------------------*\n");
printf("\n\nHow many players are there? (1-4 recommended): ");
fgets(buffer, sizeof(buffer) + 1, stdin);
fflush(stdin);
numPlayers = atoi(buffer);
while(numPlayers <= 0 || numPlayers > 10) {
printf("\nThat amount can't play. Try again: ");
fgets(buffer, sizeof(buffer) + 1, stdin);
fflush(stdin);
numPlayers = atoi(buffer);
}
printf("%d\n", numPlayers);
return 0;
OUTPUT: