View Single Post
Old 11-14-2004, 09:45 AM   #1 (permalink)
Androto
Mac Os X User(I hate win)
 
Join Date: Oct 2004
Posts: 138
Androto is on a distinguished road
Sort of same as gamehead

I have to create a code which does the same as gamehead200's code. i did this, and got 2 errors. all i want to know is what i did wrong, i don't need a whole new code, but if you're bored and you want to write your own code from scratch, them by all means, have fun.
Code:
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
    ifstream marks("c:/temp/students.txt");
    int tempHW(0);
    struct stud
    {
        string lastname, firstname;
        float mid, final;
        vector<double> homework;
    }; 
    stud tempstud;
    vector<stud> class1;
    while (!marks.eof())
    {   
        marks >> tempstud.lastname;
        marks >> tempstud.firstname;
        marks >> tempstud.mid;
        marks >> tempstud.final;
        marks >> tempHW;
        while (tempHW != -1)
        {
            tempstud.homework.push_back(tempHW);
            marks >> tempHW;
        }    
        class1.push_back(tempstud);
    }
	cout << class1;
  system("PAUSE");	
  return 0;
}
Androto is offline   Reply With Quote