I just finished reading data from a text file into a single dimension array. My "for" statement is not outputting the data from the array. I want to output the entire array just to verify that all the data is there. However when i output an individual cell, the data goes out to the screen. What am i doing wrong? Thanks in advance!
#include <iostream>
#include <fstream>
#include <iomanip>
int main()
{
const int MAX_CELLS = 500;
int count = 0;
double Vehicles[MAX_CELLS];
ifstream vehicleFile;
char type;
string license;
double charge;
vehicleFile.open ("VEHICLE.txt");
if (!vehicleFile)
cout << "Error opening vehicle file " << endl;
vehicleFile >> type >> license ; // priming read
while (vehicleFile) { // while the read was successful
cout << count << " " << license << endl; // FOR DISPLAY ONLY
vehicleFile >> Vehicles[count]; // read into array
count++; // increment count
vehicleFile >> type >> license; // read next line
}
cout << showpoint << fixed << setprecision(2);
for ( count; count < MAX_CELLS; count++) {
cout << "Array #" << count << "is: "; // OUTPUT ARRAY
cout << Vehicles[count] << endl;
}
cout << Vehicles[8]; // READS DATA IN CELL
vehicleFile.close();
system ("pause");
return 0;
}