serialization - save and load c++ program -


OK, I thought and learned many things today and for this I want to thank the community. I have not got any collision in the streets for a few hours, but now I am stuck.

The last collision on the road to save and load my program. I have no idea where to start. I saw how frames ... and fred ... work and all the examples are for programs that are not different I do not know where to begin with my files I will put 2 functions. If someone can help me to save those people I can understand comfortably.

In gradebook

  class students {public: string final; First string; Int student_id; }; Class course {public: string name; Int course_id; Vector & lt; Students & gt; Students; }; Class gradebook {public: gradebook (); Zero addCourse (); Zero addStudent (); Private: Vector & lt; Course & gt; syllabus; };   

gradebook.cpp

  zero gradebook :: addCourse () {int i, loop = 0; Cout & lt; & Lt; "Enter the number of courses:"; Cin & gt; & Gt; Loop; (I = 0; i & lt; loop; i ++) {// Create new entry to store variables Course new entry; Cout & lt; & Lt; "Enter Course ID:"; Cin & gt; & Gt; NewEntry.course_id; Cout & lt; & Lt; "Enter the name of the course:"; Cin & gt; & Gt; NewEntry.name; // variable course set from newEntry in course Push_back (newEntry); }} Zero gradebook :: addStudent () {int i, loop = 0; Cout & lt; & Lt; "Enter the number of students:"; Cin & gt; & Gt; Loop; For (i = 0; i & lt; loop; i ++) {// Create new entry to store variables Student new entry; Cout & lt; & Lt; "Enter student ID:"; Cin & gt; & Gt; newEntry.student_id; Cout & lt; & Lt; "Enter last name: "; Cin & gt; & Gt; NewEntry.last; Cout & lt; & Lt; "Enter first name: "; Cin & gt; & Gt; NewEntry.first; // Set new variables in student courses [0] Studios Push_back (newEntry); }}   

So if a user is going to do some variables in the course and students, how will I save the data?

I do not recommend fwrite , instead of ,

Basic savings:

  offream out ("data.txt"); // save file data.txt outside & lt; & Lt; Statistics; // Use & lt; & Lt; Writing operator data   

Basic loading:

  ifstream in ("data.txt"); // Reopen the same file & gt; & Gt; Statistics; // Use & gt; & Gt;     to read operator data

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -