Im sorry if my game code is long, but, the save feature wont work. Their are no errors, but when I load the game and buy weapons the stats are correct, but when I save and load It the stats are not there. Can you please help me? Yes I have not finished mission 1 - 5 yet.

#include<iostream.h>
#include<fstream>
#include<string>
using namespace std;

char choice;
int missionNumber = 0;
int smissionNumber;
int gamsoldiers = 25;
int ricsoldiers = 25;
int galsoldiers = 25;
int salsoldiers = 25;
int amesoldiers = 25;
void mission1();
void mission2();
void mission3();
void mission4();
void mission5();
void newGame();
void loadGame();
void saveGame();
void statScreen();
int battleScreen();
void rHenchmen();
void weaponBuy();
void kMafia();
void enemyPeople();
void gambino();
void ricci();
void gallo();
void salvatore();
void american();

//Player********
string pName;
int respect = 0;
int strength = 0;
string weapons[10] = "none";
int pammo = 0;
int paccuracy = 20;
int uziammo = 0;
int uziaccuracy = 10;
int sgammo = 0;
int sgaccuracy = 5;
int arammo = 0;
int araccuracy = 50;
int srammo = 0;
int sraccuracy = 90;
int agility;
int money;
int health = 100;
int barmor = 100;
string filename;
//**************
//SVAES***************************
int sstrength;
int srespect;
int spammo;
int suziammo;
int ssgammo;
int sarammo;
int ssrammo;
int sagility;
int smoney;
int sbarmor;
int shealth;
int sgamsoldiers;
string a;
char a1;
//********************************

void ricci()
{
     system("CLS");
     cout << endl << "\tDon - Michael Ricci" << endl << endl;
     cout << "\tRight Hand Man - Antonio Gallo" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << ricsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void gallo()
{
     system("CLS");
     cout << endl << "\tDon - Alfredo Gallo" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << galsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void salvatore()
{
     system("CLS");
     cout << endl << "\tDon - Antonio Salvetore" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << salsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void american()
{
     system("CLS");
     cout << endl << "\tDon - Tom Johnson" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << amesoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}

void gambino()
{
     system("CLS");
     cout << endl << "\tDon - Lou Gambino" << endl << endl;
     cout << "\tRight Hand Man - Hank Rico" << endl << endl;
     cout << "\tLeft Hand Man - Benito Deluca" << endl << endl;
     cout << "\t" << gamsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}

void saveGame()
{
     cout << "What do you want your filename to be?" << endl;
     cin >> filename;
     
     ofstream gamefile;
     gamefile.open(filename.c_str());
     
     gamefile << smissionNumber;
     missionNumber = smissionNumber;
     
     gamefile << sstrength;
     strength = sstrength;
     
     gamefile << srespect;
     respect = srespect;
     
     gamefile << spammo;
     pammo = spammo;
     
     gamefile << suziammo;
     uziammo = suziammo;
     
     gamefile << ssgammo;
     sgammo = ssgammo;
     
     gamefile << sarammo;
     arammo = sarammo;
     
     gamefile << ssrammo;
     srammo = ssrammo;
     
     gamefile << sagility;
     agility = sagility;
     
     gamefile << smoney;
     money = smoney;
     
     gamefile << sbarmor;
     barmor = sbarmor;
     
     gamefile << srespect;
     respect = srespect;
     
     gamefile << shealth;
     health = shealth;
     
     gamefile << sgamsoldiers;
     gamsoldiers = sgamsoldiers;

     gamefile.close();
     
     battleScreen();
     
     return;
}

void enemyPeople()
{
     system("CLS");
     cout << "1.Gambino Family" << endl << endl;
     cout << "2.Ricci Family" << endl << endl;
     cout << "3.Gallo Family" << endl << endl;
     cout << "4.Salvatore Family" << endl << endl;
     cout << "5.American Mafia" << endl << endl;
     cout << "6.Back" << endl << endl;
     cin >> a1;
     switch (a1)
     {
            case '1':
                 gambino();
            case '2':
                 ricci();
            case '3':
                 gallo();
            case '4':
                 salvatore();
            case '5':
                 american();
            case '6':
                 battleScreen();
     }
     
     return;
}

void kMafia()
{
     return;
}

void weaponBuy()
{
     cout << "1.Pistol(50) $200" << endl;
     cout << "2.Uzi(300) $500" << endl;
     cout << "3.Shotgun(10) $600" << endl;
     cout << "4.Assult Rifle(500) $1000" << endl;
     cout << "5.Sniper Rifle(10) $1500" << endl;
     cout << "6.Body Armor(1) $200" << endl;
     cout << "7.Back" << endl;
     cin >> a1;
     switch (a1)
     {
            case '1':
                 if (money >= 200)
                 {
                 system("CLS");
                 cout << "Pistol Bought" << endl;
                 pammo = pammo + 50;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $200" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '2':
                 if (money >= 500)
                 {
                 system("CLS");
                 cout << "Uzi Bought" << endl;
                 uziammo = uziammo + 300;
                 money = money - 500;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $500" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '3':
                 if (money >= 600)
                 {
                 system("CLS");
                 cout << "Shotgun Bought" << endl;
                 sgammo = sgammo + 50;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $600" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '4':
                 if (money >= 1000)
                 {
                 system("CLS");
                 cout << "Assult Rifle Bought" << endl;
                 arammo = arammo + 500;
                 money = money - 1000;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $1000" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '5':
                 if (money >= 1500)
                 {
                 system("CLS");
                 cout << "Sniper Rifle Bought" << endl;
                 srammo = srammo + 10;
                 money = money - 1500;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $1500" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '6':
                 if (money >= 200)
                 {
                 system("CLS");
                 cout << "Body Armor Bought" << endl;
                 barmor = 100;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $200" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '7':
                 battleScreen();
                 
     }
     
     
     return;
}

void mission1()
{
     return;
}

void mission2()
{
     return;
}

void mission3()
{
     return;
}

void mission4()
{
     return;
}

void mission5()
{
     return;
}

void statScreen()
{
     system("CLS");
     cout << "\tRespect: " << respect << endl << endl;
     cout << "\tStrength: " << strength << endl << endl;
     cout << "\tWeapons & Ammo:" << endl << endl << "Baseball Bat" << endl << endl << "Pistol: " << pammo << endl << endl << "Uzi: " << uziammo << endl << endl << "Shotgun: " << sgammo << endl << endl;
     cout << "Assult Rifle: " << arammo << endl << endl << "Sniper Rifle: " << srammo << " \t\t\tScroll Up and Down" << endl << endl;
     cout << "\tWeapon Accuracy:" << endl << endl << "Pistol(" << paccuracy << "%)" << endl << endl << " Uzi(" << uziaccuracy << "%)" << endl << endl << " Shotgun(" << sgaccuracy << "%)" << endl << endl; 
     cout << " Assult Rifle(" << araccuracy << "%)" << endl << endl << " Sniper Rifle(" << sraccuracy << "%)" << endl << endl << endl;
     cout << "\tMission " << missionNumber << "/5" << endl << endl;
     cout << "\tMoney: $" << money << endl << endl;
     cout << "\tHealth: " << health << endl << endl;
     cout << "\tBody Armor: " << barmor << endl << endl;
     
     system("PAUSE");
     battleScreen();
     
     return;
}

int battleScreen()
{
     system("CLS");
     money = 200;
     cout << "Gambino: By the way, kid, heres a baseball bat, and body armor.";
     cout << endl << endl << endl;
     cout << "\t1.Save Game" << endl;
     cout << "\t2.Continue Missions " << missionNumber << "/5" << endl;
     cout << "\t3.Check Stats" << endl;
     cout << "\t4.Buy Weapons" << endl;
     cout << "\t5.Kill Mafia" << endl;
     cout << "\t6.Enemy Gang People" << endl;
     cin >> choice;
     switch (choice)
     {
            case '1':
                 saveGame();
            case '2':
                 switch (missionNumber)
                 {
                        case 1:
                             mission1();
                        case 2:
                             mission2();
                        case 3:
                             mission3();
                        case 4:
                             mission4();
                        case 5:
                             mission5();
                 }
            case '3':
                 statScreen();
            case '4':
                 weaponBuy();
            case '5':
                 if (respect != 100)
                 {
                             system("CLS");
                             cout << "Sorry, you have to be 100 respect to use this feature" << endl;
                             system("PAUSE");
                             battleScreen();
                 }
                 else
                 {
                     kMafia();
                 }
            case '6':
                 enemyPeople();                 
     }
     
     return 0;
}

void newGame()
{
     //Intro
     system("CLS");
     cout << "You are walking home from school..." << endl << endl;
     system("PAUSE");
     cout << endl;
     cout << "BAM!! You and your books fall to the floor" << endl << endl;
     system("PAUSE");
     system("CLS");
     cout << "Punk1: Thats what you get for messin' with the Gallo Family." << endl << endl;
     cout << "The punks run but..." << endl << endl;
     cout << "WHACK!! An unknown person hits the punks with a baseball bat." << endl << endl;
     system("PAUSE");
     system("CLS");
     cout << "The unknown person is walking slowly towards you..." << endl << endl;
     system("PAUSE");
     cout << endl;
     cout << "Unknown Person: Are you okay?" << endl << endl;
     cout << "You: Yea I'm okay." << endl << endl;
     cout << "Gambino: Good. My name is Don Gambino. Whats yours?" << endl;
     cin >> pName;
     cout << "Gambino: Nice to meet you " << pName << endl << endl;
     cout << "Gambino: Would ya do to those guys?" << endl << endl;
     cout << "You: Umm... I... hit them." << endl << endl;
     cout << "Gambino: Oh. I see. How wold you like to get some revenge on those guys?" << endl << endl;
     cout << "You: Sure!" << endl << endl;
     cout << "Gambino: Come with me." << endl << endl;
     system("PAUSE");
     battleScreen();
     
     return;
}

void loadGame()
{
     cout << "What was your filename?" << endl;
     cin >> filename;
     ifstream gamefile;
     gamefile.open(filename.c_str());
     if (!gamefile)
     {
                   cout << "Invalid name please enter again" << endl;
                   system("PAUSE");
                   loadGame();
     }
     
     gamefile >> missionNumber;
     smissionNumber = missionNumber;
     
     gamefile >> strength;
     sstrength = strength;
     
     gamefile >> respect;
     srespect = respect;
     
     gamefile >> pammo;
     spammo = pammo;
     
     gamefile >> uziammo;
     suziammo = uziammo;
     
     gamefile >> sgammo;
     ssgammo = sgammo;
     
     gamefile >> arammo;
     sarammo = arammo;
     
     gamefile >> srammo;
     ssrammo = srammo;
     
     gamefile >> agility;
     sagility = agility;
     
     gamefile >> money;
     smoney = money;
     
     gamefile >> barmor;
     sbarmor = barmor;
     
     gamefile >> respect;
     srespect = respect;
     
     gamefile >> gamsoldiers;
     sgamsoldiers = gamsoldiers;
     
     gamefile.close();
     
     battleScreen();
          return;
}

main()
{
      cout << "     -----------------------------------------------------------------" << endl;
      cout << "     |                         Welcome To                            |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     |                       The Mafia Game                          |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     -----------------------------------------------------------------" << endl << endl << endl << endl;
      cout << "\t1.New Game" << endl;
      cout << "\t2.Load Game" << endl;
      cout << "\t3.Exit" << endl;
      cout << "\t";
      cin >> choice;
      switch (choice)
      {
             case '1':
                  newGame();
             case '2':
                  loadGame();
             case '3':
                  break;
      }
      
      system("PAUSE");
      return 0;
}

Thank you.

Use code=c++ in your code tags to get syntax highlighting. It makes the code a lot easier to read.

iostream.h doesn't actually exist (according to the C++ standard). Consider using

#include <iostream>
using namespace std;

instead.

Anyway. The problem is that you're writing a lot of numbers to a text file. Writing 1, 22, and 333 the way you have it would probably end up as "122333" in the file. Trying to read this in again would result in one number.

In other words, you need to print some whitespace (a space, a newline) after each number that you write to the file. Rest assured that the file reading will automatically skip over the whitespace.

You can see what's happening by examining the saved file by hand. It'll likely be a bunch of digits all on one line.

Do you mean like this:

gamefile << smissionNumber;
     missionNumber = smissionNumber;

     gamefile << "   ";

     gamefile << sstrength;
     strength = sstrength;

Thank you again.

Do you mean like this:

gamefile << smissionNumber;
     missionNumber = smissionNumber;

     gamefile << "   ";

     gamefile << sstrength;
     strength = sstrength;

Thank you again.

You need to put white space between every separate piece of information when you save. The above line that you have does put white space in so put that line ( gamefile << " "; ) on lines 11, 14, 17, 20, 23, etc., through line 47 below:

void saveGame()
{
     cout << "What do you want your filename to be?" << endl;
     cin >> filename;
     
     ofstream gamefile;
     gamefile.open(filename.c_str());
     
     gamefile << smissionNumber;
     missionNumber = smissionNumber;
     
     gamefile << sstrength;
     strength = sstrength;
     
     gamefile << srespect;
     respect = srespect;
     
     gamefile << spammo;
     pammo = spammo;
     
     gamefile << suziammo;
     uziammo = suziammo;
     
     gamefile << ssgammo;
     sgammo = ssgammo;
     
     gamefile << sarammo;
     arammo = sarammo;
     
     gamefile << ssrammo;
     srammo = ssrammo;
     
     gamefile << sagility;
     agility = sagility;
     
     gamefile << smoney;
     money = smoney;
     
     gamefile << sbarmor;
     barmor = sbarmor;
     
     gamefile << srespect;
     respect = srespect;
     
     gamefile << shealth;
     health = shealth;
     
     gamefile << sgamsoldiers;
     gamsoldiers = sgamsoldiers;

     gamefile.close();
     
     battleScreen();
     
     return;
}

Like dwks mentioned, you can open up your file in a text editor to make sure all the different pieces of information have spaces, tabs, or newlines between them. You don't want them all bunched up without spaces because then the >> operator won't know when one piece of information stops and the next starts and you'll get results that you don't want. Stick the spaces in between and >> will know when to stop.

Vernon, thank you again for helping me. Unfortunately, it doesn't work. This is my code. I put white spaces in the save function but It still will not save. Thank you again.

#include<iostream.h>
#include<fstream>
#include<string>
using namespace std;

char choice;
int missionNumber = 0;
int smissionNumber;
int gamsoldiers = 25;
int ricsoldiers = 25;
int galsoldiers = 25;
int salsoldiers = 25;
int amesoldiers = 25;
void mission1();
void mission2();
void mission3();
void mission4();
void mission5();
void newGame();
void loadGame();
void saveGame();
void statScreen();
int battleScreen();
void rHenchmen();
void weaponBuy();
void kMafia();
void enemyPeople();
void gambino();
void ricci();
void gallo();
void salvatore();
void american();

//Player********
string pName;
int respect = 0;
int strength = 0;
string weapons[10] = "none";
int pammo = 0;
int paccuracy = 20;
int uziammo = 0;
int uziaccuracy = 10;
int sgammo = 0;
int sgaccuracy = 5;
int arammo = 0;
int araccuracy = 50;
int srammo = 0;
int sraccuracy = 90;
int agility;
int money;
int health = 100;
int barmor = 100;
string filename;
//**************
//SVAES***************************
int sstrength;
int srespect;
int spammo;
int suziammo;
int ssgammo;
int sarammo;
int ssrammo;
int sagility;
int smoney;
int sbarmor;
int shealth;
int sgamsoldiers;
string a;
char a1;
//********************************

void ricci()
{
     system("CLS");
     cout << endl << "\tDon - Michael Ricci" << endl << endl;
     cout << "\tRight Hand Man - Antonio Gallo" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << ricsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void gallo()
{
     system("CLS");
     cout << endl << "\tDon - Alfredo Gallo" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << galsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void salvatore()
{
     system("CLS");
     cout << endl << "\tDon - Antonio Salvetore" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << salsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void american()
{
     system("CLS");
     cout << endl << "\tDon - Tom Johnson" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << amesoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}

void gambino()
{
     system("CLS");
     cout << endl << "\tDon - Lou Gambino" << endl << endl;
     cout << "\tRight Hand Man - Hank Rico" << endl << endl;
     cout << "\tLeft Hand Man - Benito Deluca" << endl << endl;
     cout << "\t" << gamsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}

void saveGame()
{
     cout << "What do you want your filename to be?" << endl;
     cin >> filename;
     
     ofstream gamefile;
     gamefile.open(filename.c_str());
     
     gamefile << smissionNumber;
     missionNumber = smissionNumber;
     gamefile << " ";
     gamefile << sstrength;
     strength = sstrength;
     gamefile << " ";
     gamefile << srespect;
     respect = srespect;
     gamefile << " ";
     gamefile << spammo;
     pammo = spammo;
     gamefile << " ";
     gamefile << suziammo;
     uziammo = suziammo;
     gamefile << " ";
     gamefile << ssgammo;
     sgammo = ssgammo;
     gamefile << " ";
     gamefile << sarammo;
     arammo = sarammo;
     gamefile << " ";
     gamefile << ssrammo;
     srammo = ssrammo;
     gamefile << " ";
     gamefile << sagility;
     agility = sagility;
     gamefile << " ";
     gamefile << smoney;
     money = smoney;
     gamefile << " ";
     gamefile << sbarmor;
     barmor = sbarmor;
     gamefile << " ";
     gamefile << srespect;
     respect = srespect;
     gamefile << " ";
     gamefile << shealth;
     health = shealth;
     gamefile << " ";
     gamefile << sgamsoldiers;
     gamsoldiers = sgamsoldiers;

     gamefile.close();
     
     battleScreen();
     
     return;
}

void enemyPeople()
{
     system("CLS");
     cout << "1.Gambino Family" << endl << endl;
     cout << "2.Ricci Family" << endl << endl;
     cout << "3.Gallo Family" << endl << endl;
     cout << "4.Salvatore Family" << endl << endl;
     cout << "5.American Mafia" << endl << endl;
     cout << "6.Back" << endl << endl;
     cin >> a1;
     switch (a1)
     {
            case '1':
                 gambino();
            case '2':
                 ricci();
            case '3':
                 gallo();
            case '4':
                 salvatore();
            case '5':
                 american();
            case '6':
                 battleScreen();
     }
     
     return;
}

void kMafia()
{
     return;
}

void weaponBuy()
{
     cout << "1.Pistol(50) $200" << endl;
     cout << "2.Uzi(300) $500" << endl;
     cout << "3.Shotgun(10) $600" << endl;
     cout << "4.Assult Rifle(500) $1000" << endl;
     cout << "5.Sniper Rifle(10) $1500" << endl;
     cout << "6.Body Armor(1) $200" << endl;
     cout << "7.Back" << endl;
     cin >> a1;
     switch (a1)
     {
            case '1':
                 if (money >= 200)
                 {
                 system("CLS");
                 cout << "Pistol Bought" << endl;
                 pammo = pammo + 50;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $200" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '2':
                 if (money >= 500)
                 {
                 system("CLS");
                 cout << "Uzi Bought" << endl;
                 uziammo = uziammo + 300;
                 money = money - 500;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $500" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '3':
                 if (money >= 600)
                 {
                 system("CLS");
                 cout << "Shotgun Bought" << endl;
                 sgammo = sgammo + 50;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $600" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '4':
                 if (money >= 1000)
                 {
                 system("CLS");
                 cout << "Assult Rifle Bought" << endl;
                 arammo = arammo + 500;
                 money = money - 1000;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $1000" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '5':
                 if (money >= 1500)
                 {
                 system("CLS");
                 cout << "Sniper Rifle Bought" << endl;
                 srammo = srammo + 10;
                 money = money - 1500;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $1500" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '6':
                 if (money >= 200)
                 {
                 system("CLS");
                 cout << "Body Armor Bought" << endl;
                 barmor = 100;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $200" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '7':
                 battleScreen();
                 
     }
     
     
     return;
}

void mission1()
{
     return;
}

void mission2()
{
     return;
}

void mission3()
{
     return;
}

void mission4()
{
     return;
}

void mission5()
{
     return;
}

void statScreen()
{
     system("CLS");
     cout << "\tRespect: " << respect << endl << endl;
     cout << "\tStrength: " << strength << endl << endl;
     cout << "\tWeapons & Ammo:" << endl << endl << "Baseball Bat" << endl << endl << "Pistol: " << pammo << endl << endl << "Uzi: " << uziammo << endl << endl << "Shotgun: " << sgammo << endl << endl;
     cout << "Assult Rifle: " << arammo << endl << endl << "Sniper Rifle: " << srammo << " \t\t\tScroll Up and Down" << endl << endl;
     cout << "\tWeapon Accuracy:" << endl << endl << "Pistol(" << paccuracy << "%)" << endl << endl << " Uzi(" << uziaccuracy << "%)" << endl << endl << " Shotgun(" << sgaccuracy << "%)" << endl << endl; 
     cout << " Assult Rifle(" << araccuracy << "%)" << endl << endl << " Sniper Rifle(" << sraccuracy << "%)" << endl << endl << endl;
     cout << "\tMission " << missionNumber << "/5" << endl << endl;
     cout << "\tMoney: $" << money << endl << endl;
     cout << "\tHealth: " << health << endl << endl;
     cout << "\tBody Armor: " << barmor << endl << endl;
     
     system("PAUSE");
     battleScreen();
     
     return;
}

int battleScreen()
{
     system("CLS");
     money = 200;
     cout << "Gambino: By the way, kid, heres a baseball bat, and body armor.";
     cout << endl << endl << endl;
     cout << "\t1.Save Game" << endl;
     cout << "\t2.Continue Missions " << missionNumber << "/5" << endl;
     cout << "\t3.Check Stats" << endl;
     cout << "\t4.Buy Weapons" << endl;
     cout << "\t5.Kill Mafia" << endl;
     cout << "\t6.Enemy Gang People" << endl;
     cin >> choice;
     switch (choice)
     {
            case '1':
                 saveGame();
            case '2':
                 switch (missionNumber)
                 {
                        case 1:
                             mission1();
                        case 2:
                             mission2();
                        case 3:
                             mission3();
                        case 4:
                             mission4();
                        case 5:
                             mission5();
                 }
            case '3':
                 statScreen();
            case '4':
                 weaponBuy();
            case '5':
                 if (respect != 100)
                 {
                             system("CLS");
                             cout << "Sorry, you have to be 100 respect to use this feature" << endl;
                             system("PAUSE");
                             battleScreen();
                 }
                 else
                 {
                     kMafia();
                 }
            case '6':
                 enemyPeople();                 
     }
     
     return 0;
}

void newGame()
{
     //Intro
     system("CLS");
     cout << "You are walking home from school..." << endl << endl;
     system("PAUSE");
     cout << endl;
     cout << "BAM!! You and your books fall to the floor" << endl << endl;
     system("PAUSE");
     system("CLS");
     cout << "Punk1: Thats what you get for messin' with the Gallo Family." << endl << endl;
     cout << "The punks run but..." << endl << endl;
     cout << "WHACK!! An unknown person hits the punks with a baseball bat." << endl << endl;
     system("PAUSE");
     system("CLS");
     cout << "The unknown person is walking slowly towards you..." << endl << endl;
     system("PAUSE");
     cout << endl;
     cout << "Unknown Person: Are you okay?" << endl << endl;
     cout << "You: Yea I'm okay." << endl << endl;
     cout << "Gambino: Good. My name is Don Gambino. Whats yours?" << endl;
     cin >> pName;
     cout << "Gambino: Nice to meet you " << pName << endl << endl;
     cout << "Gambino: Would ya do to those guys?" << endl << endl;
     cout << "You: Umm... I... hit them." << endl << endl;
     cout << "Gambino: Oh. I see. How wold you like to get some revenge on those guys?" << endl << endl;
     cout << "You: Sure!" << endl << endl;
     cout << "Gambino: Come with me." << endl << endl;
     system("PAUSE");
     battleScreen();
     
     return;
}

void loadGame()
{
     cout << "What was your filename?" << endl;
     cin >> filename;
     ifstream gamefile;
     gamefile.open(filename.c_str());
     if (!gamefile)
     {
                   cout << "Invalid name please enter again" << endl;
                   system("PAUSE");
                   loadGame();
     }
     
     gamefile >> missionNumber;
     smissionNumber = missionNumber;
     
     gamefile >> strength;
     sstrength = strength;
     
     gamefile >> respect;
     srespect = respect;
     
     gamefile >> pammo;
     spammo = pammo;
     
     gamefile >> uziammo;
     suziammo = uziammo;
     
     gamefile >> sgammo;
     ssgammo = sgammo;
     
     gamefile >> arammo;
     sarammo = arammo;
     
     gamefile >> srammo;
     ssrammo = srammo;
     
     gamefile >> agility;
     sagility = agility;
     
     gamefile >> money;
     smoney = money;
     
     gamefile >> barmor;
     sbarmor = barmor;
     
     gamefile >> respect;
     srespect = respect;
     
     gamefile >> gamsoldiers;
     sgamsoldiers = gamsoldiers;
     
     gamefile.close();
     
     battleScreen();
          return;
}

main()
{
      cout << "     -----------------------------------------------------------------" << endl;
      cout << "     |                         Welcome To                            |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     |                       The Mafia Game                          |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     -----------------------------------------------------------------" << endl << endl << endl << endl;
      cout << "\t1.New Game" << endl;
      cout << "\t2.Load Game" << endl;
      cout << "\t3.Exit" << endl;
      cout << "\t";
      cin >> choice;
      switch (choice)
      {
             case '1':
                  newGame();
             case '2':
                  loadGame();
             case '3':
                  break;
      }
      
      system("PAUSE");
      return 0;
}

Vernon, thank you again for helping me. Unfortunately, it doesn't work. This is my code. I put white spaces in the save function but It still will not save. Thank you again.

It does save. It may not save correctly, but it saves and it puts the spaces in between. Run the game and save it, then open the text file and you probably have all zeroes or all junk values. That's because you the variables that you are saving are never changed in the game. Take spammo for instance. Do a search for it in your program and you'll find that the only time it ever changes is in the loadGame function. Nowhere else is it ever changed, so it's going to be zero or it's going to be whatever the compiler initialized it to initially. I imagine the same is true for your other variables that you output to the file in saveGame, so that's your problem. If these variables are supposed to change somewhere before you save them, they aren't, or at least spammo does not.

Vernon again thanks for your help. But I found something. I gave myself $200 in the game, and bought a pistol. It was showing up after a bought it. After I saved It, I immediately checked my stats and the pistol was gone. I have the problem. But I don't know how to fix it.
Thanks.

Vernon again thanks for your help. But I found something. I gave myself $200 in the game, and bought a pistol. It was showing up after a bought it. After I saved It, I immediately checked my stats and the pistol was gone. I have the problem. But I don't know how to fix it.
Thanks.

Here's your battleScreen() function. Look at line 4. You are reinitializing money to 200 every time this function is called. If money should only be initialized to 200 once and you intend to call battleScreen() more than once, then take line 4 out here and initialize money to 200 somewhere else that is only executed once, perhaps in main or when you originally declare money (i.e. change the line

int money;

to

int money = 200;

above main when it is first declared).

int battleScreen()
{
     system("CLS");
     money = 200;
     cout << "Gambino: By the way, kid, heres a baseball bat, and body armor.";
     cout << endl << endl << endl;
     cout << "\t1.Save Game" << endl;
     cout << "\t2.Continue Missions " << missionNumber << "/5" << endl;
     cout << "\t3.Check Stats" << endl;
     cout << "\t4.Buy Weapons" << endl;
     cout << "\t5.Kill Mafia" << endl;
     cout << "\t6.Enemy Gang People" << endl;
     cin >> choice;
     switch (choice)
     {
            case '1':
                 saveGame();
            case '2':
                 switch (missionNumber)
                 {
                        case 1:
                             mission1();
                        case 2:
                             mission2();
                        case 3:
                             mission3();
                        case 4:
                             mission4();
                        case 5:
                             mission5();
                 }
            case '3':
                 statScreen();
            case '4':
                 weaponBuy();
            case '5':
                 if (respect != 100)
                 {
                             system("CLS");
                             cout << "Sorry, you have to be 100 respect to use this feature" << endl;
                             system("PAUSE");
                             battleScreen();
                 }
                 else
                 {
                     kMafia();
                 }
            case '6':
                 enemyPeople();                 
     }
     
     return 0;
}

Thank you Vernon, the money does decrease, but when I buy a pistol for $200 and go to stats it says I have $0 and 50 pistol ammo witch is correct. When I save it though It basicaly erases everything. I opened the file. It said this: 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I tested something too. If I change those numbers, It changes the variables in the game. So I think my code Is saving all of the variables as 0. I changed some code like you said. Here it is

#include<iostream.h>
#include<fstream>
#include<string>
using namespace std;

char choice;
int missionNumber = 0;
int smissionNumber;
int gamsoldiers = 25;
int ricsoldiers = 25;
int galsoldiers = 25;
int salsoldiers = 25;
int amesoldiers = 25;
void mission1();
void mission2();
void mission3();
void mission4();
void mission5();
void newGame();
void loadGame();
void saveGame();
void statScreen();
int battleScreen();
void rHenchmen();
void weaponBuy();
void kMafia();
void enemyPeople();
void gambino();
void ricci();
void gallo();
void salvatore();
void american();

//Player********
string pName;
int respect;
int strength;
string weapons[10] = "none";
int pammo;
int paccuracy = 20;
int uziammo;
int uziaccuracy = 10;
int sgammo;
int sgaccuracy = 5;
int arammo;
int araccuracy = 50;
int srammo;
int sraccuracy = 90;
int agility;
int money = 200;
int health = 100;
int barmor = 100;
string filename;
//**************
//SVAES***************************
int sstrength;
int srespect;
int spammo;
int suziammo;
int ssgammo;
int sarammo;
int ssrammo;
int sagility;
int smoney;
int sbarmor;
int shealth;
int sgamsoldiers;
string a;
char a1;
//********************************

void ricci()
{
     system("CLS");
     cout << endl << "\tDon - Michael Ricci" << endl << endl;
     cout << "\tRight Hand Man - Antonio Gallo" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << ricsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void gallo()
{
     system("CLS");
     cout << endl << "\tDon - Alfredo Gallo" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << galsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void salvatore()
{
     system("CLS");
     cout << endl << "\tDon - Antonio Salvetore" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << salsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}
void american()
{
     system("CLS");
     cout << endl << "\tDon - Tom Johnson" << endl << endl;
     cout << "\tRight Hand Man - ~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\tLeft Hand Man - ~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
     cout << "\t" << amesoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}

void gambino()
{
     system("CLS");
     cout << endl << "\tDon - Lou Gambino" << endl << endl;
     cout << "\tRight Hand Man - Hank Rico" << endl << endl;
     cout << "\tLeft Hand Man - Benito Deluca" << endl << endl;
     cout << "\t" << gamsoldiers << " Soldiers" << endl << endl;
     system("PAUSE");
     enemyPeople();
     
     return;
}

void saveGame()
{
     cout << "What do you want your filename to be?" << endl;
     cin >> filename;
     
     ofstream gamefile;
     gamefile.open(filename.c_str());
     
     missionNumber = smissionNumber;
     gamefile << smissionNumber;
     gamefile << "\n";
     
     gamefile << sstrength;
     strength = sstrength;
     gamefile << "\n";
     
     gamefile << srespect;
     respect = srespect;
     gamefile << "\n";
     
     pammo = spammo;
     gamefile << spammo;
     gamefile << "\n";
     
     gamefile << suziammo;
     uziammo = suziammo;
     gamefile << "\n";
     
     gamefile << ssgammo;
     sgammo = ssgammo;
     gamefile << "\n";
     
     gamefile << sarammo;
     arammo = sarammo;
     gamefile << " ";
     
     gamefile << ssrammo;
     srammo = ssrammo;
     gamefile << " ";
     
     gamefile << sagility;
     agility = sagility;
     gamefile << " ";
     
     gamefile << smoney;
     money = smoney;
     gamefile << " ";
     
     gamefile << sbarmor;
     barmor = sbarmor;
     gamefile << " ";
     
     gamefile << srespect;
     respect = srespect;
     gamefile << " ";
     
     gamefile << shealth;
     health = shealth;
     gamefile << " ";
     
     gamefile << sgamsoldiers;
     gamsoldiers = sgamsoldiers;

     gamefile.close();
     
     battleScreen();
     
     return;
}

void enemyPeople()
{
     system("CLS");
     cout << "1.Gambino Family" << endl << endl;
     cout << "2.Ricci Family" << endl << endl;
     cout << "3.Gallo Family" << endl << endl;
     cout << "4.Salvatore Family" << endl << endl;
     cout << "5.American Mafia" << endl << endl;
     cout << "6.Back" << endl << endl;
     cin >> a1;
     switch (a1)
     {
            case '1':
                 gambino();
            case '2':
                 ricci();
            case '3':
                 gallo();
            case '4':
                 salvatore();
            case '5':
                 american();
            case '6':
                 battleScreen();
     }
     
     return;
}

void kMafia()
{
     return;
}

void weaponBuy()
{
     cout << "1.Pistol(50) $200" << endl;
     cout << "2.Uzi(300) $500" << endl;
     cout << "3.Shotgun(10) $600" << endl;
     cout << "4.Assult Rifle(500) $1000" << endl;
     cout << "5.Sniper Rifle(10) $1500" << endl;
     cout << "6.Body Armor(1) $200" << endl;
     cout << "7.Back" << endl;
     cin >> a1;
     switch (a1)
     {
            case '1':
                 if (money >= 200)
                 {
                 system("CLS");
                 cout << "Pistol Bought" << endl;
                 pammo = pammo + 50;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $200" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '2':
                 if (money >= 500)
                 {
                 system("CLS");
                 cout << "Uzi Bought" << endl;
                 uziammo = uziammo + 300;
                 money = money - 500;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $500" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '3':
                 if (money >= 600)
                 {
                 system("CLS");
                 cout << "Shotgun Bought" << endl;
                 sgammo = sgammo + 50;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $600" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '4':
                 if (money >= 1000)
                 {
                 system("CLS");
                 cout << "Assult Rifle Bought" << endl;
                 arammo = arammo + 500;
                 money = money - 1000;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $1000" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '5':
                 if (money >= 1500)
                 {
                 system("CLS");
                 cout << "Sniper Rifle Bought" << endl;
                 srammo = srammo + 10;
                 money = money - 1500;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $1500" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '6':
                 if (money >= 200)
                 {
                 system("CLS");
                 cout << "Body Armor Bought" << endl;
                 barmor = 100;
                 money = money - 200;
                 system("PAUSE");
                 weaponBuy();
                 }
                 else
                 {
                     cout << "You need at least $200" << endl;
                     system("PAUSE");
                     weaponBuy();
                 }
                 
                 case '7':
                 battleScreen();
                 
     }
     
     
     return;
}

void mission1()
{
     return;
}

void mission2()
{
     return;
}

void mission3()
{
     return;
}

void mission4()
{
     return;
}

void mission5()
{
     return;
}

void statScreen()
{
     system("CLS");
     cout << "\tRespect: " << respect << endl << endl;
     cout << "\tStrength: " << strength << endl << endl;
     cout << "\tWeapons & Ammo:" << endl << endl << "Baseball Bat" << endl << endl << "Pistol: " << pammo << endl << endl << "Uzi: " << uziammo << endl << endl << "Shotgun: " << sgammo << endl << endl;
     cout << "Assult Rifle: " << arammo << endl << endl << "Sniper Rifle: " << srammo << " \t\t\tScroll Up and Down" << endl << endl;
     cout << "\tWeapon Accuracy:" << endl << endl << "Pistol(" << paccuracy << "%)" << endl << endl << " Uzi(" << uziaccuracy << "%)" << endl << endl << " Shotgun(" << sgaccuracy << "%)" << endl << endl; 
     cout << " Assult Rifle(" << araccuracy << "%)" << endl << endl << " Sniper Rifle(" << sraccuracy << "%)" << endl << endl << endl;
     cout << "\tMission " << missionNumber << "/5" << endl << endl;
     cout << "\tMoney: $" << money << endl << endl;
     cout << "\tHealth: " << health << endl << endl;
     cout << "\tBody Armor: " << barmor << endl << endl;
     
     system("PAUSE");
     battleScreen();
     
     return;
}

int battleScreen()
{
     system("CLS");
     cout << "Gambino: By the way, kid, heres a baseball bat, and body armor.";
     cout << endl << endl << endl;
     cout << "\t1.Save Game" << endl;
     cout << "\t2.Continue Missions " << missionNumber << "/5" << endl;
     cout << "\t3.Check Stats" << endl;
     cout << "\t4.Buy Weapons" << endl;
     cout << "\t5.Kill Mafia" << endl;
     cout << "\t6.Enemy Gang People" << endl;
     cin >> choice;
     switch (choice)
     {
            case '1':
                 saveGame();
            case '2':
                 switch (missionNumber)
                 {
                        case 1:
                             mission1();
                        case 2:
                             mission2();
                        case 3:
                             mission3();
                        case 4:
                             mission4();
                        case 5:
                             mission5();
                 }
            case '3':
                 statScreen();
            case '4':
                 weaponBuy();
            case '5':
                 if (respect != 100)
                 {
                             system("CLS");
                             cout << "Sorry, you have to be 100 respect to use this feature" << endl;
                             system("PAUSE");
                             battleScreen();
                 }
                 else
                 {
                     kMafia();
                 }
            case '6':
                 enemyPeople();                 
     }
     
     return 0;
}

void newGame()
{
     //Intro
     system("CLS");
     cout << "You are walking home from school..." << endl << endl;
     system("PAUSE");
     cout << endl;
     cout << "BAM!! You and your books fall to the floor" << endl << endl;
     system("PAUSE");
     system("CLS");
     cout << "Punk1: Thats what you get for messin' with the Gallo Family." << endl << endl;
     cout << "The punks run but..." << endl << endl;
     cout << "WHACK!! An unknown person hits the punks with a baseball bat." << endl << endl;
     system("PAUSE");
     system("CLS");
     cout << "The unknown person is walking slowly towards you..." << endl << endl;
     system("PAUSE");
     cout << endl;
     cout << "Unknown Person: Are you okay?" << endl << endl;
     cout << "You: Yea I'm okay." << endl << endl;
     cout << "Gambino: Good. My name is Don Gambino. Whats yours?" << endl;
     cin >> pName;
     cout << "Gambino: Nice to meet you " << pName << endl << endl;
     cout << "Gambino: Would ya do to those guys?" << endl << endl;
     cout << "You: Umm... I... hit them." << endl << endl;
     cout << "Gambino: Oh. I see. How wold you like to get some revenge on those guys?" << endl << endl;
     cout << "You: Sure!" << endl << endl;
     cout << "Gambino: Come with me." << endl << endl;
     system("PAUSE");
     battleScreen();
     
     return;
}

void loadGame()
{
     cout << "What was your filename?" << endl;
     cin >> filename;
     ifstream gamefile;
     gamefile.open(filename.c_str());
     if (!gamefile)
     {
                   cout << "Invalid name please enter again" << endl;
                   system("PAUSE");
                   loadGame();
     }
     
     gamefile >> missionNumber;
     smissionNumber = missionNumber;
     
     gamefile >> strength;
     sstrength = strength;
     
     gamefile >> respect;
     srespect = respect;
     
     gamefile >> pammo;
     spammo = pammo;
     
     gamefile >> uziammo;
     suziammo = uziammo;
     
     gamefile >> sgammo;
     ssgammo = sgammo;
     
     gamefile >> arammo;
     sarammo = arammo;
     
     gamefile >> srammo;
     ssrammo = srammo;
     
     gamefile >> agility;
     sagility = agility;
     
     gamefile >> money;
     smoney = money;
     
     gamefile >> barmor;
     sbarmor = barmor;
     
     gamefile >> respect;
     srespect = respect;
     
     gamefile >> gamsoldiers;
     sgamsoldiers = gamsoldiers;
     
     gamefile.close();
     
     battleScreen();
          return;
}

int main()
{
      system("TITLE Mafia Game");
      cout << "     -----------------------------------------------------------------" << endl;
      cout << "     |                         Welcome To                            |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     |                       The Mafia Game                          |" << endl;
      cout << "     |                                                               |" << endl;
      cout << "     -----------------------------------------------------------------" << endl << endl << endl << endl;
      cout << "\t1.New Game" << endl;
      cout << "\t2.Load Game" << endl;
      cout << "\t3.Exit" << endl;
      cout << "\t";
      cin >> choice;
      switch (choice)
      {
             case '1':
                  newGame();
             case '2':
                  loadGame();
             case '3':
                  break;
      }
      
      system("PAUSE");
      return 0;
}

Here is the application if you want to do what I did:
1. New Game
2. Buy Weapon
3. Pistol
4. Check stats (should be $0 and scroll up, 50 pistol)
5. Save Game
6. Check Stats
7. EVERYTHING IS GONE!!!:@

switch (choice)
     {
            case '1':
                 saveGame();
            case '2':
                 switch (missionNumber)
                 {
                        case 1:
                             mission1();
                        case 2:
                             mission2();
                        case 3:
                             mission3();
                        case 4:
                             mission4();
                        case 5:
                             mission5();
                 }
            case '3':
                 statScreen();
            case '4':
                 weaponBuy();
            case '5':
                 if (respect != 100)
                 {
                             system("CLS");
                             cout << "Sorry, you have to be 100 respect to use this feature" << endl;
                             system("PAUSE");
                             battleScreen();
                 }
                 else
                 {
                     kMafia();
                 }
            case '6':
                 enemyPeople();                 
     }

Remember that you need break statements to end each case . . . .

Comments
Good observation! =)
This article has been dead for over six months. Start a new discussion instead.