Advertisement
Guest User

Untitled

a guest
Sep 26th, 2018
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. const int SIZE = 30;
  8.  
  9.  
  10. struct studentType {
  11.     string fName, lName, email;
  12.     int ID;
  13.     double GPA;
  14. };
  15.  
  16. typedef struct studentType S;
  17.  
  18. class student {
  19.  
  20. private:
  21.     int items;
  22. public:
  23.     student();
  24.     ~student();
  25.  
  26.     void addData(string f, string l, double g, int i, string e, S *list[]);
  27.  
  28. };
  29.  
  30. int main() {
  31.     ifstream fin;
  32.     string f, l, e;
  33.     int i;
  34.     double g;
  35.  
  36.     student student;
  37.     S sList[SIZE];
  38.     S *list[SIZE];
  39.  
  40.     fin.open("records.txt");
  41.     if (!fin) {
  42.         cout << "File could not be opened." << endl;
  43.     }
  44.  
  45.     cout << "Gathering info...";
  46.  
  47.     while (fin >> f >> l >> g >> i >> e) {
  48.         student.addData(f, l, g, i, e, list);
  49.  
  50.     }
  51.     cout << "Gathering complete." << endl;
  52.  
  53.     system("pause");
  54.     return 0;
  55.  
  56. }
  57.  
  58. student::student() : items(0) {
  59.     S *pList[SIZE];
  60. }
  61. student::~student() {}
  62.  
  63. void student::addData(string f, string l, double g, int i, string e, S *list[]) {
  64.     /*list[0]->fName = "hello";
  65.     cout << list[0] << endl;*/
  66.     /*list[items]->fName = f;
  67.     list[items]->lName = l;
  68.     list[items]->GPA = g;
  69.     list[items]->ID = i;
  70.     list[items]->email = e;
  71.     items++;*/
  72. }
  73.  
  74. /*Taylor Hicks       2.50 883991892 howhicks@yahoo.com
  75. Maria Mirzaie      2.98 886653142 tziirii@gmail.com
  76. Leetal Cohen       3.68 880702399 leetalcohen@gmail.com
  77. Michael Kouji      3.98 889385022 astromichael@gmail.com
  78. Danielle Haerblond 2.80 888302743 DaniGeo@aol.com
  79. Maria Mirzaie      2.68 882323494 tziirii@gmail.com
  80. Joe Cottoneye      1.42 880381938 longtimag0@gmail.com
  81. Dale Fields        3.41 881234567 fieldsdl@yahoo.com
  82. Roy Brooder        2.00 880987654 roeebroods@yahoo.com
  83. Kailey Yelliac     1.98 886657820 sensorikalie@hotmail.com 
  84. Zach Dontknowwho   2.78 881027840 donahuezachary@yahoo.com*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement