(the number of integers in each line is the same, but it is unknown)
So I may have a file like this:
title1 34 98 title2 15 9 title3 45 15
or
title1 34 98 76 97 title2 15 9 43 8 title3 45 15 34 7
or ...
struct elem
{
char d[50];
int v[50];
};
I tried this and it compiles but doesn't work
char ch;
elem col[10];
int num,z=0;
//z-nr of lines, num -nr of int values in the line
ifstream myfile("t2.txt");
if (myfile.is_open())
{
while (myfile.good())
{
myfile>>col[z].d;
num=0;
myfile.get(ch);
while(ch!='\n')
{
myfile>>col[z].v[num];
myfile.get(ch);
num++;
}
z++;
}
myfile.close();
}
the program 'hangs' (the not responding state)