In the following code i get a bug which i cannot get rid of. The exe shows last verse twice. How can I fix this? (file contains text in this format: 1;name ;1;name2 ;2 \n 1;name2 ;1;name3 ;2
void WZ(string nazwa)
{
std::fstream plik;
plik.open( nazwa.c_str() );
while( true )
{
if( plik.good() )
{
int oferta;
string dane;
int ilosc;
string koszyk;
int status;
int licznik=0;
for(int a=0; a<5;a++)
{
plik>>oferta;
plik.ignore( numeric_limits < streamsize >::max(), ';' );
plik>>dane;
plik.ignore( numeric_limits < streamsize >::max(), ';' );
plik>>ilosc;
plik.ignore( numeric_limits < streamsize >::max(), ';' );
plik>>koszyk;
plik.ignore( numeric_limits < streamsize >::max(), ';' );
plik>>status;
licznik++;
cout<<oferta<<dane<<ilosc<<koszyk<<status<<"licznik: "<<licznik<<endl;
}
}
else
{
break; //zakoñcz wczytywanie danych - wyst¹pi³ jakiœ b³¹d (np. nie ma wiêcej danych w pliku)
}
}
}