This is the code I have so far. I am getting my data from an input file. The file has all the data that I need for each variable that I am calling but when I run it I only get one iteration and it exits the loop after that. I need it to run till it reaches the end of the file.
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
int main ()
{
ifstream pTemp("PlanetCelsius.dat");
int pNumber, pSize;
string pName;
double cTemp, fTemp;
cout << "Number\t" << "Planet Name\t" << "Diameter\t" << "Celsius\t" << "Fahrenheit" << endl;
while (pTemp >> pNumber)
{
while (pTemp >> pName)
{
while (pTemp >> pSize)
{
while (pTemp >> cTemp)
{
pTemp >> pNumber;
cout << pNumber << " ";
}
pTemp >> pName;
cout << pName << " ";
}
pTemp >> pSize;
cout << pSize << " ";
}
pTemp >> cTemp;
fTemp = 9 * (cTemp) / 5 + 32;
cout << cTemp << " " << fTemp << endl;
}
system ("PAUSE");
return 0;
}