title: save and load c++ program
body: <p>Ok so I figured out and learned a lot of stuff today and I want to thank the community for that. I haven't had any bump in the roads for a few hours now but now I'm stuck.</p>
  
  <p>The last bump in the road. Saving and Loading my program. I have no idea where to start. I looked at  how fwrite... and fread... works and all the examples are for programs that aren't split. I don't know where to start with my files. I'll put up 2 functions. If someone can help me how to do save those I can probably figure out the rest.</p>
  
  <p>in gradebook.h</p>
  
  <pre><code>class Student {
   public: 
    string last;
    string first;
    int student_id;
  };
  
  class Course {
   public:
    string name;
    int course_id;
    vector &lt;Student&gt; students;
  };
  
  class Gradebook {
   public:
    Gradebook();
    void addCourse();
    void addStudent();
   private:
    vector &lt;Course&gt; courses;
  };
  </code></pre>
  
  <p>in gradebook.cpp</p>
  
  <pre><code>void Gradebook::addCourse() {
  
   int i, loop=0;
  
      cout &lt;&lt; "Enter Number of Courses: ";
  cin &gt;&gt; loop;
  
  for(i=0; i&lt;loop; i++) {
  
      //create newEntry to store variables
      Course newEntry;
  
      cout &lt;&lt; "Enter Course ID: ";
      cin &gt;&gt; newEntry.course_id;
  
      cout &lt;&lt; "Enter Course Name: ";
      cin &gt;&gt; newEntry.name;
  
      //set variables from newEntry in Courses
      courses.push_back(newEntry);
  
  }
  
  }
  void Gradebook::addStudent() {
  
      int i, loop=0;
  
  cout &lt;&lt; "Enter Number of Students: ";
  cin &gt;&gt; loop;
  
  for(i=0; i&lt;loop; i++) {
  
      //create newEntry to store variables
      Student newEntry; 
  
      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 variables from newEntry in Students
      courses[0].students.push_back(newEntry);
  
  }
  }
  </code></pre>
  
  <p>So if a user was to input some variables in courses and students how would i use fwrite... to save the data?</p>