string comma;
92 string line;
93 ifstream myfile("student.dat");
94 string name,email="";
95 string status="";
96 int id;
97 if (myfile.is_open()){
98 while ( getline (myfile,line) ) {
99 //parse line
100 string myText(line);
101 // cout<<line<<endl;
102 istringstream iss(myText);
103 if (!(iss>>id)) id=0;
104 Student newStudent(id,line,"","");
105 Student::studentList.insert(std::pair<int,Student>(id,newStudent));
106 }
Line 104 does not quite accomplish what I desire.
public:
19 static Student findStudent(int ID);
20 static map<int,Student> studentList;
21 Student(int ID, string name, string gradeStatus,string email):Id(ID),name(name),status(gradeStatus),emailAddress(email){};
Above is where the constructor is defined. I am lost on how to parse the string and then apply each piece as parameters.
Also here is an example line from the file: 0,0,person name,freshman,email@stuff.com