Hello! The text file is separated by tabs..I have used a struc as below:
struct scores
{ int maths
int phy;
int bio;
int chem;
int eng;
int total;
};
struct class
{ int class_id;
char name[50];
};
ifstream fin;
fin.open("marks.txt");
char buf[100];
string a;
getline(fin,a);
char delims[] = "\t";
for(int i=0; i<a.size(); i++)
{
buf[i] = a[i];
}
char *result = NULL;
result = strtok( buf, delims );
while( result != NULL ) {
printf( "result is \"%s\"\n", result );
result = strtok( NULL, delims );
}
when i compile i get: (I have just read one line of the text file)
result is 67
result is 34
result is 34
result is 90
result is 67
result is 76
result is 2
result is Science_G
Now i need to store each column(eng marks,phy marks,..) in an array
as i need to sort them later..
I think i have to use getnexttoken..
can someone guide me how to do it?