I have a file, that has a list of about 300 cities and its cost of living index. Example: 115.3 San Jose, Ca etc. I wrote a program that reads in this data:
while (inputFile.peek() != EOF)
{
inputFile >> *(costIndexPtr + i);
while (inputFile.peek() == ' ')
inputFile.get();
getline(inputFile, *(cityPtr + i));
i++; //used to keep track of how many cities total
}
I also wrote code to output the data:
for (int i = 0; i < (num - 1); i++)
{
cout << left << setw(7) << costIndexPtr[i] << " 1" << cityPtr[i]
<< "1" << endl;
outputFile << left << setw(7) << costIndexPtr[i] << " "
<< cityPtr[i] << endl;
}
However, when the actual data the is output is as follows: