This is my sample text file enter image description here
1 Class Physics American 3.6 5 Maria Garcia 1-541-754-3010
2 Class Chemical Australian 3.5 4 Maria Hernandez 1-541-754-3233
And I have a group of array and variable.
typedef struct
{
double current;
unsigned int subject;
}CGPA;
typedef struct
{
char program[40];
char state[50];
char name[50];
char contact[50];
string studentid;
CGPA a;
}INFOR;
How can I store them in different variable for later processing use?
Here are the some part of my code but it cannot get the correct value and store them to my struct array from my txt file:
for( int i = 0; getline(readfile, line); i++)
{
//getline(readfile,student[i].id, '\0');
//getline(readfile,student[i].a.subject, '\0');
//strcpy(student[i].subject, temporary_s);
readfile >> student[i].studentid >> student[i].program >> student[i].state >> student[i].a.current >> student[i].a.subject >> student[i].name >> student[i].contact; //This is my code cannot read my text file correctly
++line_count;
}
This is my sample output: enter image description here I want to delete certain line, update certain line of my file and show up the lower or higher CGPA, this is why i need to restore my text file value to the array for later processing use.
This code cannot read my file in right way, I don't know to to deal with it
readfile >> student[i].studentid >> student[i].program >> student[i].state >> student[i].a.current >>student[i].a.subject >> student[i].name >> student[i].contact; //This is my code cannot read my text file correct