I am trying to read a string from a formatted file using ifstream >>. This is the code fragment:
float o, h, l, c, uv, dv, spx;
char type, date[10];
string datestr;
if(infile >> date >> o >> h >> l >> c >> type)
{
datestr = date; // put array into string
outfile << datestr.c_str() << '\t' << setprecision(2) << fixed << o << '\t' << h << '\t' << l << '\t' << c << '\t' << type << endl;
}
I could not find a way so I read it into a char[10] then assigned that to a string. Is there a way to read the string from the disk directly into a string?