The problem is, that whenver it boots up the file, it doesn't get
all of the numbers... I have the variable 'nex' returning '0' on
of the variables that don't read in as what they're supposed to.

I don't want to hear complaints of how 'horrid' my code is. It's mine,
and I'll write it how I want. Thank you.
//Code by: Ne0v001
//http://s7.invisionfree.com/Ne0v001_Game/
//ne0v001@yahoo.com
//This file has all the startup and shutdown functions
//used for booting up and shutting down in game systems
//version 0.1.1.9

#ifndef _STARTSTOP_
#define _STARTSTOP_
//file needed for file I/O
#include
//needed for some string manip stuff
#include
//stats.h (you should know what it is)
#include "stats.h"

//usings.... bleh
using namespace std;

ifstream fp, file, filepointer, spd;

//when it all starts up
void startup()
{
//string to write into
char string[256];
cout << "Getting ifstream files..." << endl;

fp.open("stats.txt");
int loop = 1, nex;
while (loop <= 10) {
fp >> string;
if (loop == 1) {
strcpy(character.name, string);
}
if (loop == 2) {
strcpy(character.pass, string);
}
if (loop > 2) {
fp >> nex;
}
switch(loop) {
case 3:
character.atk = nex;
break;
case 4:
character.def = nex;
break;
case 5:
character.sp_atk = nex;
break;
}
loop++;
nex = 0;
}
fp.close();

loop = 1;

file.open("ostats.txt");
while (loop <= 7) {
file >> nex;
switch(loop) {
case 1:
character.mining = nex;
break;
case 2:
character.woodcut = nex;
break;
case 3:
character.firemake = nex;
break;
case 4:
character.alchemy = nex;
break;
case 5:
character.constitution = nex;
break;
case 6:
character.strength = nex;
break;
case 7:
character.agility = nex;
break;
}
loop++;
nex = 0;
}
file.close();

loop = 1;

filepointer.open("istats.txt");
while(loop <= 10) {
filepointer >> nex;
switch(loop){
case 1:
character.endurance = nex;
break;
case 2:
character.intelligence = nex;
break;
case 3:
character.wisdom = nex;
break;
case 4:
character.charisma = nex;
break;
case 5:
character.stealth = nex;
break;
case 6:
character.awareness = nex;
break;
case 7:
equip.equipweight = nex;
break;
case 8:
pack.packweight = nex;
break;
case 9:
character.tothp = nex;
break;
case 10:
character.totmp = nex;
break;
}
loop++;
nex = 0;
}
filepointer.close();

loop = 1;

spd.open("pstats.txt");
while(loop <= 4) {
switch(loop){
case 1:
character.sp_def = nex;
break;
case 2:
character.spd = nex;
break;
case 3:
character.curhp = nex;
break;
case 4:
character.curmp = nex;
break;
case 5:
character.acc = nex;
break;
}
loop++;
}
spd.close();

cout << "ifstream files loaded..." << endl;

cout << "Loaded all stats" << endl;
}

//when the program shutsdown
void shutdown()
{
//opening the file to write into
std::fstream Output("stats.txt", std::ios::out | std::ios::trunc);
//outputting all the stats
Output << character.name << std::endl;
Output << character.pass << std::endl;
Output << character.atk << std::endl;
Output << character.def << std::endl;
Output << character.sp_atk << std::endl;

Output.close();
std::fstream Output2("ostats.txt", std::ios::out | std::ios::trunc);

Output2 << character.mining << std::endl;
Output2 << character.woodcut << std::endl;
Output2 << character.firemake << std::endl;
Output2 << character.alchemy << std::endl;
Output2 << character.constitution << std::endl;
Output2 << character.strength << std::endl;
Output2 << character.agility << std::endl;

Output2.close();
std::fstream Output3("istats.txt", std::ios::out | std::ios::trunc);

Output3 << character.endurance << std::endl;
Output3 << character.intelligence << std::endl;
Output3 << character.wisdom << std::endl;
Output3 << character.charisma << std::endl;
Output3 << character.stealth << std::endl;
Output3 << character.awareness << std::endl;
Output3 << equip.equipweight << std::endl;
Output3 << pack.packweight << std::endl;
Output3 << character.tothp << std::endl;
Output3 << character.totmp << std::endl;
//closing the file
Output3.close();

std::fstream Output4("pstats.txt", std::ios::out | std::ios::trunc);
Output4 << character.sp_def << std::endl;
Output4 << character.spd << std::endl;
Output4 << character.curhp << std::endl;
Output4 << character.curmp << std::endl;
Output4 << character.acc << std::endl;
Output4.close();

cout << "Stats saved..." << endl;
}

#endif

Contents of the files

stats.txt:
Ne0v001
poopoo
5
5
5

ostats.txt:
5
5
5
5
5
5
5

istats.txt:
5
5
5
5
5
5
5
5
5
5

pstats.txt:
5
5
5
5
5