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++;  
             }
             }

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.