Need help fixing my c++ fighting game with Run-Time Check Error : I have been receiving an issue that I do not understand. The issue is "Run-Time Check Failure #3 - The variable 'win' is being used without being initialized.". I am struggling to comprehend where my error is within the code. May someone please explain to me where it is? From what I understand the run time error comes from win not being initialized meaning it hasn't been used or set, however, it clearly is set in the fightScene() function.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    #include "Character.h"
    #include "Item.h"
    #include "Blacksmith.h"

    using namespace std;

    void startup();
    void createCharacter();
    void existCharacter();
    void secondFighter();
    void fightScene();
    int fightMoves(int att, int sp, int num);
    void roundWon();
    void characterLost();
    void use_bar();
    void newlines();
    void changeCase(string &convert);
    void bSmith();

    Character existingCharacter[4] = { Character("Shabu", 10, 10, 10, 0, "Empty"), Character("Calil", 15, 15, 15, 0, "Empty"), Character("Goltero", 20, 20, 20, 0, "Empty"), Character("Balrogg", 30, 30, 30, 0, "Empty") };
    Character cCharacter[2] = { Character(), Character() };
    Character cCharacterSave("Empty", 20, 0, 0, 100, "Empty");
    Item bars(0, 0, 0);
    int timesWon = 0;
    int purposeIgnore = 0;
    char repeat = 'y';

    int main() {
    	startup();
    	while (repeat == 'y' || repeat == 'Y') {
    		fightScene();
    		if (repeat == 'y' || repeat == 'Y')
    			secondFighter();
    	}
    	return 0;
    }

    void startup() {
    	int playerChoice;
    	cout << "**************************" << endl;
    	cout << "*      Loading Game      *" << endl;
    	cout << "**************************" << endl;
    	cout << "Which Would You Prefer?" << endl;
    	cout << "1: New Character..." << endl;
    	cout << "2: Load Character..." << endl;

    	do {
    		cout << "Enter Selection: ";
    		cin >> playerChoice;
    	} while (playerChoice <= 0 || playerChoice >= 3);
    	if (playerChoice == 1)
    		createCharacter();
    	else if (playerChoice == 2)
    		existCharacter();
    	return;
    }

    void createCharacter() {
    	string Name;
    	string inventory;
    	int h, att, sp, gc;

    	cout << "***************************" << endl;
    	cout << "*   Creating New Player   *" << endl;
    	cout << "***************************" << endl;
    	cout << "What Shall We Call You?" << endl;
    	cout << "Enter Name Here: ";
    	
    	cin >> Name;
    	changeCase(Name);
    	
    	cout << Name << ", let's set your stats!" << endl;
    	cout << "Set your ATTACK between 1 - 10" << endl;

    	do {
    		cout << "Enter Attack Here: ";
    		cin >> att;
    	} while (att <= 0 || att >= 11);

    	cout << "Set your SPEED between 1 - 10" << endl;

    	do {
    		cout << "Enter Speed Here: ";
    		cin >> sp;
    	} while (sp <= 0 || sp >= 11);

    	h = 20;
    	gc = 100;

    	cout << "The HEALTH stat wil increase over time, but as of now, " << Name << ", has " << h << " health!" << endl;
    	cout << Name << " you have been granted " << gc << " gold!" << endl;

    	cCharacter[0] = Character(Name, h, att, sp, gc, inventory);
    	cin.ignore();
    	return;
    }

    void existCharacter() {
    	string characterChoice;
    	
    	cout << "***********************" << endl;
    	cout << "*   Existing Player   *" << endl;
    	cout << "***********************" << endl;

    	for (int i = 0, j = 1; i >= 0 && i <= 3; i++, j++) {
    		cout << j << ": " << existingCharacter[i].getName();
    		cout << "\t" << "Health: " << existingCharacter[i].getHealth();
    		cout << "\t" << "Attack: " << existingCharacter[i].getAttack();
    		cout << "\t" << "Speed: " << existingCharacter[i].getSpeed();
    	}

    	cout << "Enter Selection: ";

    	cin.ignore();
    	getline(cin, characterChoice);
    	changeCase(characterChoice);

    	if (characterChoice == "1" || characterChoice == "Shabu") {
    		cCharacter[0] = existingCharacter[0]; cCharacterSave.setHealth(existingCharacter[0].getHealth());
    	}
    	else if (characterChoice == "2" || characterChoice == "Calil") {
    		cCharacter[0] = existingCharacter[1]; cCharacterSave.setHealth(existingCharacter[1].getHealth());
    	}
    	else if (characterChoice == "3" || characterChoice == "Goltero") {
    		cCharacter[0] = existingCharacter[2]; cCharacterSave.setHealth(existingCharacter[2].getHealth());
    	}
    	else if (characterChoice == "4" || characterChoice == "Balrogg") {
    		cCharacter[0] = existingCharacter[3]; cCharacterSave.setHealth(existingCharacter[3].getHealth());
    	}
    	else {
    		cout << "Program Failure....Invaid Input!" << endl;
    	}
    	secondFighter();
    	return;
    }

    void secondFighter() {
    	string cFighter;

    	cout << "***************" << endl;
    	cout << "*   Fighter   *" << endl;
    	cout << "***************" << endl;
    	cout << "Choose Who To Fight!" << endl;

    	for (int i = 0, j = 1; i >= 0 && i <= 3; i++, j++) {
    		cout << j << ": " << existingCharacter[i].getName();
    		cout << "\t" << "Health: " << existingCharacter[i].getHealth();
    		cout << "\t" << "Strength: " << existingCharacter[i].getAttack();
    		cout << "\t" << "Speed: " << existingCharacter[i].getSpeed();
    		cout << endl;
    	}

    	cout << "Enter Selection: ";
    	if (purposeIgnore >= 1)
    		cin.ignore();

    	getline(cin, cFighter);
    	changeCase(cFighter);

    	if (cFighter == "1" || cFighter == "Shabu")
    		cCharacter[1] = existingCharacter[0];
    	else if (cFighter == "2" || cFighter == "Calil")
    		cCharacter[1] = existingCharacter[1];
    	else if (cFighter == "3" || cFighter == "Goltero")
    		cCharacter[1] = existingCharacter[2];
    	else if (cFighter == "4" || cFighter == "Balrogg")
    		cCharacter[1] = existingCharacter[3];
    	else { cout << "Invalid Input! Program Failure....Please Close and Restart" << endl; }

    	return;
    }

    void fightScene() {
    	int fight_choice;
    	int i = 0;
    	int j = 5;
    	bool win;

    	if (timesWon >= 1)
    		j = 6;

    	while (cCharacter[0].getHealth() > 0 && cCharacter[1].getHealth() > 0) {
    		newlines();

    		cout << "\t\t" << cCharacter[0].getName() << " choose ";

    		if (i == 0)
    			cout << "an attack.";

    		else
    			cout << "another attack.";

    		do {
    			cout << "\n\n\t\t<1. Punch / 2. Kick>\n\t\t<3. Slam / 4. Drop kick>";

    			if (j == 6)
    				cout << "\n\t\t<5. Items>";

    			cout << endl << "\t\t";
    			cin >> fight_choice;
    		} while (fight_choice <= 0 || fight_choice >= j);

    		if (fight_choice == 1) {
    			cCharacter[1].setHealth(cCharacter[1].getHealth() - fightMoves(cCharacter[0].getAttack(), cCharacter[0].getSpeed(), 1));
    			cout << "\n\t\tYou Punched " << cCharacter[1].getName() << ", his health is now: ";

    			if (cCharacter[1].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[1].setHealth(-1);
    			}

    			else
    				cout << cCharacter[1].getHealth() << endl << endl;
    		}

    		else if (fight_choice == 2) {
    			cCharacter[1].setHealth(cCharacter[1].getHealth() - fightMoves(cCharacter[0].getAttack(), cCharacter[0].getSpeed(), 2));
    			cout << "\n\t\tYou Kicked " << cCharacter[1].getName() << ", his health is now: ";

    			if (cCharacter[1].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[1].setHealth(-1);
    			}

    			else
    				cout << cCharacter[1].getHealth() << endl << endl;
    		}

    		else if (fight_choice == 3) {
    			cCharacter[1].setHealth(cCharacter[1].getHealth() - fightMoves(cCharacter[0].getAttack(), cCharacter[0].getSpeed(), 3));
    			cout << "\n\t\tYou Slamed " << cCharacter[1].getName() << " on the ground, his health is now: ";

    			if (cCharacter[1].getHealth() <= 0)

    			{
    				cout << "0" << endl << endl; cCharacter[1].setHealth(-1);
    			}

    			else
    				cout << cCharacter[1].getHealth() << endl << endl;
    		}

    		else if (fight_choice == 4) {
    			cCharacter[1].setHealth(cCharacter[1].getHealth() - fightMoves(cCharacter[0].getAttack(), cCharacter[0].getSpeed(), 4));
    			cout << "\n\t\tYou Drop Kicked " << cCharacter[1].getName() << ", his health is now: ";

    			if (cCharacter[1].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[1].setHealth(-1);
    			}

    			else
    				cout << cCharacter[1].getHealth() << endl << endl;
    		}

    		else if (timesWon >= 1 && fight_choice == 5) { // Bars
    			use_bar();
    		}

    		// Second fighter attack

    		srand(time(NULL));
    		int ran_pick = rand() % 5 + 1;

    		if (cCharacter[1].getHealth() < 0) {
    			ran_pick = 0;
    			win = 1;
    		}

    		else if (cCharacter[1].getHealth() > 0) {
    			cout << "\n\t\t<" << cCharacter[1].getName() << "'s turn>" << endl;
    			win = 0;
    		}

    		if (ran_pick == 0)
    			continue;

    		else if (ran_pick == 1) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() - fightMoves(cCharacter[1].getAttack(), cCharacter[1].getSpeed(), 1));
    			cout << "\n\t\t" << cCharacter[1].getName() << " punched you! Your health is now: ";

    			if (cCharacter[0].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[0].setHealth(-1);
    			}

    			else
    				cout << cCharacter[0].getHealth() << endl << endl;
    		}

    		else if (ran_pick == 2) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() - fightMoves(cCharacter[1].getAttack(), cCharacter[1].getSpeed(), 2));
    			cout << "\n\t\t" << cCharacter[1].getName() << " kicked you! Your health is now: ";

    			if (cCharacter[0].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[0].setHealth(-1);
    			}

    			else
    				cout << cCharacter[0].getHealth() << endl << endl;
    		}

    		else if (ran_pick == 3) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() - fightMoves(cCharacter[1].getAttack(), cCharacter[1].getSpeed(), 3));
    			cout << "\n\t\t" << cCharacter[1].getName() << " slammed you on the ground! Your health is now: ";

    			if (cCharacter[0].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[0].setHealth(-1);
    			}

    			else
    				cout << cCharacter[0].getHealth() << endl << endl;
    		}

    		else if (ran_pick == 4) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() - fightMoves(cCharacter[1].getAttack(), cCharacter[1].getSpeed(), 4));
    			cout << "\n\t\t" << cCharacter[1].getName() << " drop kicked you! Your health is now: ";

    			if (cCharacter[0].getHealth() <= 0)
    			{
    				cout << "0" << endl << endl; cCharacter[0].setHealth(-1);
    			}

    			else
    				cout << cCharacter[0].getHealth() << endl << endl;
    		}

    		else if (ran_pick == 5)
    			cout << "\t\t" << cCharacter[1].getName() << " missed you! Your health is still: " << cCharacter[0].getHealth() << endl << endl;

    		if (cCharacter[0].getHealth() > 0) {
    			cout << "\n\t\t";
    			system("PAUSE"); // Lets them read the attacks
    		}

    		i++; // Increases i to change some wording
    	}

    	if (win == 1)
    		roundWon();

    	else
    		characterLost();

    	return;
    }

    int fightMoves(int st, int sp, int num) {
    	srand(time(NULL));
    	int rand_num;
    	int addition;

    	switch (num) {
    	case 1: {
    		rand_num = rand() % 40 + 1;
    		addition = (st + sp) / rand_num;
    		cout << "\n\t\tDamage inflicted: " << addition;
    		return addition; break;
    	}
    	case 2: {
    		rand_num = rand() % 20 + 1;
    		addition = (st + sp) / rand_num;
    		cout << "\n\t\tDamage inflicted: " << addition;
    		return addition; break;
    	}
    	case 3: {
    		rand_num = rand() % 30 + 1;
    		addition = (st + sp) / rand_num;
    		cout << "\n\t\tDamage inflicted: " << addition;
    		return addition; break;
    	}
    	case 4: {
    		rand_num = rand() % 30 + 1;
    		addition = (st + sp) / rand_num;
    		cout << "\n\t\tDamage inflicted: " << addition;
    		return addition; break;
    	}
    	}
    }

    int start()
    {
    	while (repeat == 'y' || repeat == 'Y') {
    		fightScene();
    		if (repeat == 'y' || repeat == 'Y')
    			secondFighter();
    	}
    	return 0;
    }

    void roundWon() {
    	srand(time(NULL));
    	timesWon++;
    	purposeIgnore++;
    	cCharacter[0].setHealth(cCharacterSave.getHealth());
    	cCharacter[1].setHealth(100);
    	int item_won = rand() % 3 + 1;

    	cout << "\t\tYou won!";
    	cout << "\n\n\t\tYou have been rewarded ";

    	if (item_won == 1) {
    		cout << "a small protein bar! (+20 health)";
    		bars.bar_small++;
    	}

    	else if (item_won == 2) {
    		cout << "a medium protein bar! (+30 health)";
    		bars.bar_medium++;
    	}

    	else if (item_won == 3) {
    		cout << "a large protein bar! (+40 health)";
    		bars.bar_large++;
    	}

    	cout << "\n\n\t\tItems can be used in game at the cost of a turn.";

    	cout << "\n\n\t\t";
    	system("PAUSE"); // Lets them read

    	int ability_gain[3] = { rand() % 10 + 1, rand() % 10 + 1, rand() % 10 + 1 };

    	cCharacter[0].setHealth(ability_gain[0] += cCharacter[0].getHealth());
    	cCharacterSave.setHealth(cCharacter[0].getHealth());
    	cCharacter[0].setAttack(ability_gain[1] += cCharacter[0].getAttack());
    	cCharacter[0].setSpeed(ability_gain[2] += cCharacter[0].getSpeed());

    	cout << "\n\t\tYour health is now: " << cCharacter[0].getHealth();
    	cout << "\n\t\tYour strength is now: " << cCharacter[0].getAttack();
    	cout << "\n\t\tYour speed is now: " << cCharacter[0].getSpeed();

    	cout << "\n\n\t\tWould you like to fight another person? (y/n) ";
    	cin >> repeat;

    	return;
    }

    void characterLost() {
    	cCharacter[0].setHealth(cCharacterSave.getHealth());
    	cCharacter[1].setHealth(100);
    	purposeIgnore++;

    	cout << "\n\n\t\tYou have lost.";
    	cout << "\n\t\tWould you like to fight another person? (y/n) ";
    	cin >> repeat;

    	return;
    }

    void use_bar() {
    	int choose_bar;
    	char another_bar;

    	do {
    		cout << "\n\n\t\tWhich bar would you like to use? ";
    		cout << "\n\t\t 1: Small Bar: " << bars.bar_small;
    		cout << "\n\t\t 2: Medium Bar: " << bars.bar_medium;
    		cout << "\n\t\t 3: Large bar: " << bars.bar_large;

    		do {
    			cout << "\n\n\t\tI choose: ";
    			cin >> choose_bar;
    		} while (choose_bar <= 0 || choose_bar >= 4);

    		if (choose_bar == 1 && bars.bar_small >= 1) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() + 20);
    			bars.bar_small--;
    			cout << "\n\n\t\tYour health is now: " << cCharacter[0].getHealth();
    		}

    		else if (choose_bar == 2 && bars.bar_medium >= 1) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() + 30);
    			bars.bar_medium--;
    			cout << "\n\n\t\tYour health is now: " << cCharacter[0].getHealth();
    		}

    		else if (choose_bar == 3 && bars.bar_large >= 1) {
    			cCharacter[0].setHealth(cCharacter[0].getHealth() + 40);
    			bars.bar_large--;
    			cout << "\n\n\t\tYour health is now: " << cCharacter[0].getHealth();
    		}

    		else
    			cout << "\n\t\tNot enough bars!";

    		cout << "\n\n\t\tWould you like to use another bar? (y/n) ";
    		cin >> another_bar;
    	} while (another_bar == 'y' || another_bar == 'Y');

    	return;
    }

    void newlines() {
    	cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
    }

    void changeCase(string &convert) {
    	for (int i = 0; convert[i]; i++) {
    		if (isupper(convert[i]))
    			convert[i] = tolower(convert[i]);
    		else
    			continue;
    	}

    	convert.at(0) = toupper(convert.at(0));

    	return;
    }

    void bSmith()
    {
    	Blacksmith shopKeeper; //The shop keeper

    	int responce; //Menu navigation
    	cout << "*******************************" << endl;
    	cout << "*  Welcome to the Blacksmith  *" << endl;
    	cout << "*******************************" << "\n" << endl;

    	cout << "*****************************" << endl;
    	cout << "*     1: Purchase Items     *\n";
    	cout << "*       2: Sell Items       *\n";
    	cout << "*    3: List Your Items     *\n";
    	cout << "*        4: Currency        *\n";
    	cout << "*          5: Exit          *\n";
    	cout << "*****************************" << endl;
    	do
    	{
    		cout << "Enter Option Here: ";
    		cin >> responce;

    		switch (responce)
    		{
    		case 1:
    			shopKeeper.buyItem(cCharacter[0]);
    			cout << endl;
    			break;

    		case 2:
    			cout << "*****************************" << endl;
    			cout << "*       Items To Sell       *" << endl;
    			cout << "*****************************" << endl;
    			shopKeeper.sellItem(cCharacter[0]);
    			cout << endl;
    			break;

    		case 3:
    			cout << "*****************************" << endl;
    			cout << "*    Character Inventory    *" << endl;
    			cout << "*****************************" << endl;
    			cCharacter[0].listInv();
    			cout << endl;
    			break;

    		case 4:
    			cout << "*****************************" << endl;
    			cout << "*   Current Gold Currency   *" << endl;
    			cout << "*****************************" << endl;
    			cout << "\t" << cCharacter[0].getCurrency() << endl;
    			cout << endl;
    			break;

    		case 5:
    			cout << "*****************************" << endl;
    			cout << "*    Thanks for shopping    *" << endl;
    			cout << "*****************************" << endl;
    			return;

    		default:
    			cout << "Please enter valid data." << "\n";
    			break;
    		}
    		cout << "*****************************" << endl;
    		cout << "*     1: Purchase Items     *\n";
    		cout << "*       2: Sell Items       *\n";
    		cout << "*    3: List Your Items     *\n";
    		cout << "*        4: Currency        *\n";
    		cout << "*          5: Exit          *\n";
    		cout << "*****************************" << endl;
    	} while (responce != 5);

    	return;
    }


<!-- end snippet -->

