I\'m trying to read a series of floats from a .out file using ifstream, but if I output them afterwards, they are not correct.
This is my input code:
I have worked with that before and something I would do is like the code below where you read your text file line by line and use getline and a string to put the twext into variables. You don't have to ue an array as it is limited to the elements but use a vector and that way you can add dynamically.
string xs;
string ys;
string zs;
ifstream infile;
someArray[50];
infile.open("some file.txt");
if (!infile)
{
cout << "no good file failed! \n" << endl;
}
while (infile.good())
{
for (int i = 0; i < 49; ++i)
{
getline(infile, xs);
//Saves the line in xs.
infile >> p[i].xs;
getline(infile, ys, ',');
infile >> p[i].ys;
getline(infile, zs, ',');
infile >> p[i].zs;
}
//infile >> p.fromFloor; */
}
infile.close();
}