Hi
I'm doing a wheel of fortune program in which the player scores are accumulated and tabulated in a 1d array player_turns[]={0,0,0}. The game has three rounds, and I don't know how to print the final score and declare a winner. I figure that it must have to do with converting the 1d array to a 2d array such as results[round_num][player_num]. Could someone please help or guide me how to do this. Thanks.
Code:int main(int argc, char* argv[]){ char phrase[NAME_LENGTH]; char puzzle[NAME_LENGTH]; char clue[NAME_LENGTH]; int puzzle_length; int round; char num_players[5]; int solved = 0; int current_player; int player_scores[NUM_PLAYERS] = {0, 0, 0}; int a=0; srand(time(0)); current_player=rand()%3+1; printf("\n"); printf("Over 50,000 in cash and prizes just waiting to be won!\n"); printf(" Here on Wheel ... of ... Fortune!\n"); printf(" (loud drum roll and music...)\n"); printf("\n"); /* Get the number of players */ while (a< 1 || a > 3){ printf("\nHow many players will be playing the game (1-3)? "); if(fgets(num_players,5,stdin)){ sscanf(num_players, "%d", &a); } printf("\n"); } /* Get the puzzle */ for(round=0; round<3; ++round){ puzzle_length = initialize_array(phrase, puzzle, clue); current_player = rand()% a; while (solved == 0) { print_score(a, player_scores); solved = player_turn(current_player, player_scores, phrase, puzzle, clue, puzzle_length); if (solved == 0){ ++current_player; if (current_player == a){ current_player = 0; } } } solved=0; current_player = rand()% a; } return(0); }



LinkBack URL
About LinkBacks


