A
andy.lee23
hi im having trouble counting lines in a text file, i have the
following code
int node1, node2, i;
char name[2];
float value;
ifstream fin;
fin.open(OpenDialog1->FileName.c_str());
i=1;
// while (!fin.eof())
for(;
{
fin>>name>>node1>>node2>>value;
switch(i){
case 1:
Label1->Caption = value;
break;
case 2:
Label2->Caption = value;
break;
case 3:
Label3->Caption = value;
break;
case 4:
Label4->Caption = value;
break;
case 5:
Label5->Caption = value;
break;
}
i++;
if (fin.eof()) break;
}
im using i to increment each time the loop goes round thus counting the
no. of lines. however the line ' fin>>name>>node1>>node2>>value;' keeps
setting i to 0 so it never counts it. How do i fix this, or is there
another way to do this?
thx
following code
int node1, node2, i;
char name[2];
float value;
ifstream fin;
fin.open(OpenDialog1->FileName.c_str());
i=1;
// while (!fin.eof())
for(;
{
fin>>name>>node1>>node2>>value;
switch(i){
case 1:
Label1->Caption = value;
break;
case 2:
Label2->Caption = value;
break;
case 3:
Label3->Caption = value;
break;
case 4:
Label4->Caption = value;
break;
case 5:
Label5->Caption = value;
break;
}
i++;
if (fin.eof()) break;
}
im using i to increment each time the loop goes round thus counting the
no. of lines. however the line ' fin>>name>>node1>>node2>>value;' keeps
setting i to 0 so it never counts it. How do i fix this, or is there
another way to do this?
thx