I have to figure out how to input some variables into a file and read them back
Code:
struct party {
char heroname[50];
int Hclass;
int hp;
int stamina;
int mp;
int damage;
}hero1;
herostats.open ("Rpg++.txt", ios::trunc | ios::in);
if (herostats.is_open()) {
cout<<"Charater creation!\n";
cout<<"What is your heros name?";
cin.getline(hero1.heroname,49,'\n');
cout<<"What is your hero class?";
cin>>hero1.Hclass;
herostats<<hero1.heroname;
herostats<<hero1.Hclass;
herostats.close();
}
else{
cout<<"Error: Couldn't create/open the file called herostats\n";
}
I was able to make it write to the file but I was wondering how would I get a certain part of the file aka only the charaters name and not the numbers with it
*Edit*I was just basically wondering how I could seperate the data and receive only that part aka lets say they enter Bob paladin 500(hp) 500(mp)
so when It writes to the file it has like a divider Bob|paladin|500|500 and I could just get like block one or two only