Greed Game Problem - Hang Up In The Middle of a Function

This is a discussion on Greed Game Problem - Hang Up In The Middle of a Function within the C Programming forums, part of the General Programming Boards category; Hello everyone, I'm having a bit of trouble with my code following through with the rest of a particular function. ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    3

    Greed Game Problem - Hang Up In The Middle of a Function

    Hello everyone,

    I'm having a bit of trouble with my code following through with the rest of a particular function. I've done some printf tests throughout and am finding that it doesn't seem to be doing anything after the user presses enter to continue on with the game.

    I know my code is long and not very efficient, but I only need to be able to present a functional program this time around and not focus on function separation and whatnot. I believe it's hung up in the diceRoll function. Any insight would be greatly appreciated

    PS - I worked in the Java environment about a year ago and haven't touched on it at all since, and am starting in C without ever having programmed in it before. I know that Java derives from C, but there's quite a bit of difference from what I can see. It wouldn't surprise me if it was something entirely mundane that I was forgetting.

    Code:
    #include <stdio.h>#include <stdlib.h>
    #include <time.h>
    
    
    char player_1[20], player_2[20];
    int player_start, points_to_win, currentPlayer, win, player1TotalScore;
    int player2TotalScore, rollScore, turnScore;
    int dice[5];
    
    
    void threePair();
    void singles();
    void sixOKind();
    void fiveOKind();
    void fourOKind();
    void triples();
    void straight();
    void six1();
    void winning();
    void diceRoll();
    
    
    int main()
    {
    	int i;
    	player1TotalScore = 0;
    	player2TotalScore = 0;
    	win = 0;
    	printf("**********************************\n");
    	printf("** Welcome to the Game of Greed **\n");
    	printf("**********************************\n\n");
    	printf("Name of player 1? ");
    	scanf("%s", player_1);
    	fflush(stdout);
    	printf("Name of player 2? ");
    	scanf("%s", player_2);
    	fflush(stdout);
    	printf("Player to start the game (1 of %s, 2 for %s)? ", player_1, player_2);
    	scanf("%d", &player_start);
    	fflush(stdout);
    	printf("Points to win the game? ");
    	scanf("%d", &points_to_win);
    	fflush(stdout);
    	for(i = 0; i < 6; i++)
    		dice[i] = 20;
    	diceRoll();
    	return 0;
    }
    
    
    void diceRoll()
    {
    	char c;
    	currentPlayer = player_start;
    	while((win == 0) && (player1TotalScore < points_to_win) && (player2TotalScore < points_to_win)) {
    		if(currentPlayer == 1) {
    			printf("%s's Turn >> Press Enter to roll the dice", player_1);
    			getch();
    			srand(time(NULL));
    
    
    			int i;
    			for(i = 0; i < 6; i++) {
    				if(dice[i] == 20 || dice[i] != 0) {
    					dice[i] = rand() % 6 + 1;
    				}
    			}
    
    
    			printf("\n%i  ", dice[0]);
    			printf("%i  ", dice[1]);
    			printf("%i  ", dice[2]);
    			printf("%i  ", dice[3]);
    			printf("%i  ", dice[4]);
    			printf("%i\t", dice[5]);
    
    
    			six1();
    			straight();
    			threePair();
    			sixOKind();
    			fiveOKind();
    			fourOKind();
    			triples();
    			singles();
    
    
    			printf("Roll Score: %i\t", rollScore);
    			printf("Turn Score: %i\n", turnScore);
    		} else if(currentPlayer == 2) {
    			printf("%s's Turn >> Press Enter to roll the dice", player_2);
    			getch();
    			srand(time(NULL));
    			int i;
    			for(i = 0; i < 6; i++) {
    				dice[i] = rand() % 6 + 1;
    			}
    
    
    			printf("\n%i  ", dice[0]);
    			printf("%i  ", dice[1]);
    			printf("%i  ", dice[2]);
    			printf("%i  ", dice[3]);
    			printf("%i  ", dice[4]);
    			printf("%i  ", dice[5]);
    
    
    			six1();
    			straight();
    			threePair();
    			sixOKind();
    			fiveOKind();
    			fourOKind();
    			triples();
    			singles();
    
    
    			printf("Roll Score: %i\t", rollScore);
    			printf("Turn Score: %i\n", turnScore);
    		}
    
    
    		winning();
    		if(win != 1) {
    			if(rollScore != 0) {
    				printf("Would you like to roll ");
    				printf("again (Y/y, N/n)?");
    				c = getchar();
    				if(c == 'Y' || c == 'y') {
    					rollScore = 0;
    					diceRoll();
    				} else if(c == 'N' || c == 'n') {
    					rollScore = 0;
    					turnScore = 0;
    					if(currentPlayer == 1)
    						currentPlayer = 2;
    					else
    						currentPlayer = 1;
    				}
    			} else if(rollScore == 0) {
    				if(currentPlayer == 1) {
    					player1TotalScore = player1TotalScore - turnScore;
    					currentPlayer = 2;
    				} else if(currentPlayer == 2) {
    					player2TotalScore = player2TotalScore - turnScore;
    					currentPlayer = 1;
    				}
    			}
    		}
    	}
    	if(currentPlayer == 1) {
    		printf("Congratulations %s!", player_1);
    		printf("You won the game!");
    	}
    	else if(currentPlayer == 2) {
    		printf("Congratulations %s!", player_2);
    		printf("You won the game!");
    	}
    }
    
    
    void winning()
    {
    	if(currentPlayer == 1) {
    		if(player1TotalScore >= points_to_win)
    			win = 1;
    		else
    			win = 0;
    
    
    	} else if(currentPlayer == 2) {
    		if(player2TotalScore >= points_to_win)
    			win = 2;
    		else
    			win = 0;
    	}
    }
    
    
    void six1()
    {
        printf("test");
    	int i;
    	int j;
    	int counter = 0;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1)
    			counter = counter + 1;
    	}
    	if(counter == 6) {
    		for(j = 0; j < 6; j++)
    			dice[i] = 0;
    		if(currentPlayer == 1) {
    			player1TotalScore = player1TotalScore + 8000;
    			rollScore = rollScore + 8000;
    			turnScore = turnScore + 8000;
    		}
    		else if(currentPlayer == 2) {
    			player2TotalScore = player2TotalScore + 8000;
    			rollScore = rollScore + 8000;
    			turnScore = turnScore + 8000;
    		}
    	}
    }
    
    
    void straight()
    {
        printf("test");
    	int one_define = 0;
    	int two_define = 0;
    	int three_define = 0;
    	int four_define = 0;
    	int five_define = 0;
    	int six_define = 0;
    	int i;
    	int j;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1 && one_define == 0)
    			one_define = 1;
    		else if(dice[i] == 2 && two_define == 0)
    			two_define = 1;
    		else if(dice[i] == 3 && three_define == 0)
    			three_define = 1;
    		else if(dice[i] == 4 && four_define == 0)
    			four_define = 1;
    		else if(dice[i] == 5 && five_define == 0)
    			five_define = 1;
    		else if(dice[i] == 6 && six_define == 0)
    			six_define = 1;
    		else
    			break;
    	}
    	if(one_define == 1 && two_define == 1 && three_define == 1 && four_define == 1
    	&& five_define == 1 && six_define == 1) {
    		for(j = 0; j < 6; j++)
    			dice[j] = 0;
    		if(currentPlayer == 1) {
    			rollScore = rollScore + 1200;
    			turnScore = turnScore + 1200;
    			player1TotalScore = player1TotalScore + 1200;
    		} else if(currentPlayer == 2) {
    			rollScore = rollScore + 1200;
    			turnScore = turnScore + 1200;
    			player2TotalScore = player2TotalScore + 1200;
    		}
    	}
    }
    
    
    void threePair() {
        printf("test");
    	int one_define = 0;
    	int two_define = 0;
    	int three_define = 0;
    	int four_define = 0;
    	int five_define = 0;
    	int six_define = 0;
    	int i;
    	int j;
    	int k;
    	int l;
    	int counter = 0;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1 && one_define != 2)
    			one_define = one_define + 1;
    		else if(dice[i] == 2 && two_define != 2)
    			two_define = two_define + 1;
    		else if(dice[i] == 3 && three_define != 2)
    			three_define = three_define + 1;
    		else if(dice[i] == 4 && four_define != 2)
    			four_define = four_define + 1;
    		else if(dice[i] == 5 && five_define != 2)
    			five_define = five_define + 1;
    		else if(dice[i] == 6 && six_define != 2)
    			six_define = six_define + 1;
    		else
    			break;
    	}
    	int defineArray[5];
    	for(j = 0; j < 6; j++) {
    		if(j == 0)
    			defineArray[j] = one_define;
    		if(j == 1)
    			defineArray[j] = two_define;
    		if(j == 2)
    			defineArray[j] = three_define;
    		if(j == 3)
    			defineArray[j] = four_define;
    		if(j == 4)
    			defineArray[j] = five_define;
    		if(j == 5)
    			defineArray[j] = six_define;
    	}
    	for(k = 0; k < 6; k++) {
    		if(defineArray[k] == 2)
    			counter = counter + 1;
    	}
    	if(counter == 3) {
    		for(l = 0; l < 6; l++)
    			dice[l] = 0;
    		if(currentPlayer == 1) {
    			player1TotalScore = player1TotalScore + 800;
    			rollScore = rollScore + 800;
    			turnScore = turnScore + 800;
    		} else if (currentPlayer == 2) {
    			player2TotalScore = player2TotalScore + 800;
    			rollScore = rollScore + 800;
    			turnScore = turnScore + 800;
    		}
    	}
    }
    
    
    void sixOKind()
    {
        printf("test");
    	int one_define = 0;
    	int two_define = 0;
    	int three_define = 0;
    	int four_define = 0;
    	int five_define = 0;
    	int six_define = 0;
    	int i;
    	int j;
    	int k;
    	int l;
    	int scoreMultiplier;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1)
    			one_define = one_define + 1;
    		else if(dice[i] == 2)
    			two_define = two_define + 1;
    		else if(dice[i] == 3)
    			three_define = three_define + 1;
    		else if(dice[i] == 4)
    			four_define = four_define + 1;
    		else if(dice[i] == 5)
    			five_define = five_define + 1;
    		else if(dice[i] == 6)
    			six_define = six_define + 1;
    		else
    			break;
    	}
    	int defineArray[5];
    	for(j = 0; j < 6; j++) {
    		if(j = 0)
    			defineArray[j] = one_define;
    		else if(j = 1)
    			defineArray[j] = two_define;
    		else if(j = 2)
    			defineArray[j] = three_define;
    		else if(j = 3)
    			defineArray[j] = four_define;
    		else if(j = 4)
    			defineArray[j] = five_define;
    		else if(j = 6)
    			defineArray[j] = six_define;
    	}
    	for(k = 0; k < 6; k++) {
    		if(defineArray[k] == 6) {
    			for(l = 0; l < 6; l++)
    				dice[l] = 0;
    			if(k == 0)
    				scoreMultiplier = 8000;
    			else if(k == 1)
    				scoreMultiplier = 1600;
    			else if(k == 2)
    				scoreMultiplier = 2400;
    			else if(k == 3)
    				scoreMultiplier = 3200;
    			else if(k == 4)
    				scoreMultiplier = 4000;
    			else if(k = 5)
    				scoreMultiplier = 4800;
    		}
    		if(currentPlayer == 1) {
    			player1TotalScore = player1TotalScore +
    			scoreMultiplier;
    			rollScore = rollScore + scoreMultiplier;
    			turnScore = turnScore + scoreMultiplier;
    		} else if (currentPlayer == 2) {
    			player2TotalScore = player2TotalScore +
    			scoreMultiplier;
    			rollScore = rollScore + scoreMultiplier;
    			turnScore = turnScore + scoreMultiplier;
    		}
    
    
    	}
    }
    
    
    void fiveOKind()
    {
        printf("test");
    	int one_define = 0;
    	int two_define = 0;
    	int three_define = 0;
    	int four_define = 0;
    	int five_define = 0;
    	int six_define = 0;
    	int i;
    	int j;
    	int k;
    	int l;
    	int scoreMultiplier;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1)
    			one_define = one_define + 1;
    		else if(dice[i] == 2)
    			two_define = two_define + 1;
    		else if(dice[i] == 3)
    			three_define = three_define + 1;
    		else if(dice[i] == 4)
    			four_define = four_define + 1;
    		else if(dice[i] == 5)
    			five_define = five_define + 1;
    		else if(dice[i] == 6)
    			six_define = six_define + 1;
    		else
    			break;
    	}
    	int defineArray[5];
    	for(j = 0; j < 6; j++) {
    		if(j = 0)
    			defineArray[j] = one_define;
    		else if(j = 1)
    			defineArray[j] = two_define;
    		else if(j = 2)
    			defineArray[j] = three_define;
    		else if(j = 3)
    			defineArray[j] = four_define;
    		else if(j = 4)
    			defineArray[j] = five_define;
    		else if(j = 6)
    			defineArray[j] = six_define;
    	}
    	for(k = 0; k < 6; k++) {
    		if(defineArray[k] == 5) {
    			if(k == 0) {
    				scoreMultiplier = 4000;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 1)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 1) {
    				scoreMultiplier = 800;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 2)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 2) {
    				scoreMultiplier = 1200;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 3)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 3) {
    				scoreMultiplier = 1600;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 4)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 4) {
    				scoreMultiplier = 2000;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 5)
    						dice[l] = 0;
    				}
    			}
    			else if(k = 5) {
    				scoreMultiplier = 2400;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 6)
    						dice[l] = 0;
    				}
    			}
    		}
    	}
    	if(currentPlayer == 1) {
    		player1TotalScore = player1TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	} else if (currentPlayer == 2) {
    		player2TotalScore = player2TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	}
    }
    
    
    void fourOKind()
    {
        printf("test");
    	int one_define = 0;
    	int two_define = 0;
    	int three_define = 0;
    	int four_define = 0;
    	int five_define = 0;
    	int six_define = 0;
    	int i;
    	int j;
    	int k;
    	int l;
    	int scoreMultiplier;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1)
    			one_define = one_define + 1;
    		else if(dice[i] == 2)
    			two_define = two_define + 1;
    		else if(dice[i] == 3)
    			three_define = three_define + 1;
    		else if(dice[i] == 4)
    			four_define = four_define + 1;
    		else if(dice[i] == 5)
    			five_define = five_define + 1;
    		else if(dice[i] == 6)
    			six_define = six_define + 1;
    		else
    			break;
    	}
    	int defineArray[5];
    	for(j = 0; j < 6; j++) {
    		if(j = 0)
    			defineArray[j] = one_define;
    		else if(j = 1)
    			defineArray[j] = two_define;
    		else if(j = 2)
    			defineArray[j] = three_define;
    		else if(j = 3)
    			defineArray[j] = four_define;
    		else if(j = 4)
    			defineArray[j] = five_define;
    		else if(j = 6)
    			defineArray[j] = six_define;
    	}
    	for(k = 0; k < 6; k++) {
    		if(defineArray[k] == 4) {
    			if(k == 0) {
    				scoreMultiplier = 2000;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 1)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 1) {
    				scoreMultiplier = 400;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 2)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 2) {
    				scoreMultiplier = 600;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 3)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 3) {
    				scoreMultiplier = 800;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 4)
    						dice[l] = 0;
    				}
    			}
    			else if(k == 4) {
    				scoreMultiplier = 1000;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 5)
    						dice[l] = 0;
    				}
    			}
    			else if(k = 5) {
    				scoreMultiplier = 1200;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 6)
    						dice[l] = 0;
    				}
    			}
    		}
    	}
    	if(currentPlayer == 1) {
    		player1TotalScore = player1TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	} else if (currentPlayer == 2) {
    		player2TotalScore = player2TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	}
    }
    
    
    void triples()
    {
        printf("test");
    	int one_define = 0;
    	int two_define = 0;
    	int three_define = 0;
    	int four_define = 0;
    	int five_define = 0;
    	int six_define = 0;
    	int i;
    	int j;
    	int k;
    	int l;
    	int scoreMultiplier;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1)
    			one_define = one_define + 1;
    		else if(dice[i] == 2)
    			two_define = two_define + 1;
    		else if(dice[i] == 3)
    			three_define = three_define + 1;
    		else if(dice[i] == 4)
    			four_define = four_define + 1;
    		else if(dice[i] == 5)
    			five_define = five_define + 1;
    		else if(dice[i] == 6)
    			six_define = six_define + 1;
    		else
    			break;
    	}
    	int defineArray[5];
    	for(j = 0; j < 6; j++) {
    		if(j = 0)
    			defineArray[j] = one_define;
    		else if(j = 1)
    			defineArray[j] = two_define;
    		else if(j = 2)
    			defineArray[j] = three_define;
    		else if(j = 3)
    			defineArray[j] = four_define;
    		else if(j = 4)
    			defineArray[j] = five_define;
    		else if(j = 6)
    			defineArray[j] = six_define;
    	}
    	for(k = 0; k < 6; k++) {
    		if(defineArray[k] == 3) {
    			if(k == 0) {
    				scoreMultiplier = scoreMultiplier
    				+ 1000;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 1)
    						dice[l] = 0;
    				}
    			}
    			if(k == 1) {
    				scoreMultiplier = scoreMultiplier
    				+ 200;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 2)
    						dice[l] = 0;
    				}
    			}
    			if(k == 2) {
    				scoreMultiplier = scoreMultiplier
    				+ 300;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 3)
    						dice[l] = 0;
    				}
    			}
    			if(k == 3) {
    				scoreMultiplier = scoreMultiplier
    				+ 400;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 4)
    						dice[l] = 0;
    				}
    			}
    			if(k == 4) {
    				scoreMultiplier = scoreMultiplier
    				+ 500;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 5)
    						dice[l] = 0;
    				}
    			}
    			if(k = 5) {
    				scoreMultiplier = scoreMultiplier
    				+ 600;
    				for(l = 0; l < 6; l++) {
    					if(dice[l] == 6)
    						dice[l] = 0;
    				}
    			}
    		}
    	}
    	if(currentPlayer == 1) {
    		player1TotalScore = player1TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	} else if (currentPlayer == 2) {
    		player2TotalScore = player2TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	}
    }
    
    
    void singles()
    {
        printf("test");
    	int one_define = 0;
    	int five_define = 0;
    	int i;
    	int j;
    	int k;
    	int l;
    	int scoreMultiplier;
    	for(i = 0; i < 6; i++) {
    		if(dice[i] == 1)
    			one_define = one_define + 1;
    		else if(dice[i] == 5)
    			five_define = five_define + 1;
    	}
    	int defineArray[1];
    	for(j = 0; j < 1; j++) {
    		if(j = 0)
    			defineArray[0] = one_define;
    		else if(j = 1)
    			defineArray[1] = five_define;
    	}
    	for(k = 0; k < 1; k++) {
    		if(k == 0) {
    			scoreMultiplier = scoreMultiplier
    			+ 100;
    			for(l = 0; l < 6; l++) {
    				if(dice[l] == 1)
    					dice[l] = 0;
    			}
    		}
    		if(k == 1) {
    			scoreMultiplier = scoreMultiplier
    			+ 50;
    			for(l = 0; l < 6; l++) {
    				if(dice[l] == 5)
    					dice[l] = 0;
    			}
    		}
    	}
    	if(currentPlayer == 1) {
    		player1TotalScore = player1TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	} else if (currentPlayer == 2) {
    		player2TotalScore = player2TotalScore +
    		scoreMultiplier;
    		rollScore = rollScore + scoreMultiplier;
    		turnScore = turnScore + scoreMultiplier;
    	}
    }
    Last edited by Newwisdom01; 01-29-2012 at 12:42 AM.

  2. #2
    Registered User
    Join Date
    Jan 2012
    Posts
    3
    *EDIT* Okay, so I've found that by using "getch()" instead of "getchar()", it will wait for the user to press enter before continuing on. I've also found out that I haven't been having it properly checking through ALL the dice in all of the logicals by using "for(i = 0; i < 5 (instead of 6); i++), so I fixed that, but now it outputs the 6 dice values, but then won't continue on from there. It's like it's not calling any of the called functions I list below the printing of the dice values. Any idea what I might be doing wrong here? Thank you!!

    *EDIT* Alright, so I did some additional tests: after putting "printf("test");" at the top of each function in the list that I call in the list, only 3 "test" prints come out. So, to me, it is indicating that it is making it through six1(), straight(), and threePair() (or maybe threePair() is where it gets hung up and doesn't want to continue - I'm not really sure). Sorry, for posting so much on my own, I just want to show that I'm trying to do individual troubleshooting and perhaps can give you a better idea of how to help me. Thanks again!

    *EDIT* Sorry, I forgot about post editing... So I've gotten a 4th "test" to show up, and it was because of an error in my logic in threePair(). I'm going to update my code with what I've got current.

    *EDIT* Okay... so I finally get the program to run all the way through. It was all issues with my for-statements and the else-if statements that were running when going through the array of "defines". Now the only problem seems to be that the math is all wrong. It seems to be adding an additional 1000 or so onto the correct total.
    Last edited by Newwisdom01; 01-29-2012 at 01:07 AM.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    I spotted some bug in there at a glance and they are ones that the compiler should pick up for you as warnings (e.g. line 691). Turn your compiler's warning level up to the max and pay attention to the warnings it then generates.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Jan 2012
    Posts
    3
    I'll have to look up how to do that in CodeBlocks. Now I added a bit of code in there as follows:
    Code:
    if(win != 1) {			if(rollScore != 0) {
    			    char yes_no;
    				printf("Would you like to roll ");
    				printf("again (Y/y, N/n)? ");
    				scanf("%c", yes_no);
    				if(yes_no == 'Y' || yes_no == 'y') {
    					rollScore = 0;
    					diceRoll();
    				} else if(yes_no == 'N' || yes_no == 'n') {
    					rollScore = 0;
    					turnScore = 0;
    					if(currentPlayer == 1)
    						currentPlayer = 2;
    					else
    						currentPlayer = 1;
    				}
    And now whenever it runs, it makes the program crash and I get a Windows notification that the program has stopped working >.>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-02-2011, 05:31 PM
  2. A problem in the middle of ... !
    By Coca cola in forum C++ Programming
    Replies: 3
    Last Post: 02-27-2011, 10:58 AM
  3. Name Problem: First, Middle, Last
    By Sedition X in forum C Programming
    Replies: 24
    Last Post: 02-02-2011, 08:33 AM
  4. problem inserting node in middle of list
    By c_weed in forum C++ Programming
    Replies: 3
    Last Post: 12-22-2010, 08:14 PM
  5. Detab Function Loop Hang
    By neu_greg in forum C Programming
    Replies: 6
    Last Post: 01-27-2009, 04:33 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21