0

It just crashes out.

{
              int i,j;
     ifstream input;
     input.open("carpark.txt");
     
     
        
          {
              for (i=0;i<j;++i)
               {
                 input >> employee[i].spotnumber;
                 input >> employee[i].driver_name;
                 input >> employee[i].car_reg;
         
                 }
              while (!input.eof())            
             j++;  
             }
             }
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jonsca
1

You don't need it:

int i = 0;
while(input>>employee[i].spotnumber)
{
      input >> employee[i].driver_name;
      input >> employee[i].car_reg;
      i++;
}

Search the threads on this site about eof and why it's not reliable. E.g., http://www.daniweb.com/forums/thread19956.html , post #18 on that thread. (that thread/article is also the 5th sticky post down at the top of this forum)

Edited by jonsca: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.