CODE:
PROBLEM:Code:#include <iostream> #include <stdlib.h> #include <wincon.h> #include <conio.h> #include <windows.h> #include <fstream> #include "gkinfo.h" using namespace std; ofstream save; ifstream load; void savestats(student &x, course *c) { clrscr(); save.open("stats.dat"); cout<<"Saving statistics..."; int i; /*save the class*/ //save << &x << endl; /*Save variables*/ save << x.FNAME<<endl; //Firstname save << x.LNAME<<endl; //Lastname save << x.ID<<endl; //Student ID /*Course variable save*/ for(i=1; i<25; i++) { //save << &c[i] << endl; save << c[i].cGrade<<endl; //Grade save << c[i].CourseName<<endl; //Course Name save << c[i].nCurrentPoints<<endl; //Current poits in class save << c[i].nMaxPoints<<endl; //Max points you got save << c[i].nHour<<endl; //Hour of class } save.close(); //close the file cout<<"Stats saved!"; } void loadstats(student &x, course *c) { clrscr(); load.open("stats.dat"); cout<<"Loading statistics..."<<endl; int j; /* load vars*/ //load >> &x; load>>x.FNAME; //First Name load>>x.LNAME; //LastName load>>x.ID; //ID for (j=25; j>1; j--) { //load >> &c[j]; load >> c[j].cGrade; load >> c[j].CourseName; load >> c[j].nCurrentPoints; load >> c[j].nMaxPoints; load >> c[j].nHour; } load.close(); cout<<x.FNAME<<"'s"<< "Stats opened!"; cin.get(); }
The problem is that the file doesn't want to load any variable other than "x.LNAME". It will load that, but none of the other variables. I have NO idea why it is loadin that one, but if somebody can help I would appreciate it
EDIT: I should note that the variables are being saved to the file (checked using a hex editor).