#include<iostream>
#include<iomanip>
#include<fstream>
#include<sstream>
#include<string>
usingnamespace std;
int main()
{
string line;
string date;
double d[5];
char c;
longlong num; // long long
ifstream in( "data.txt" );
while( getline( in, line ) ) // read a line
{
stringstream ss( line ); // set up a stringstream from the whole line
getline( ss, date, ',' ); // collect up to the comma as a date string
for ( int i = 0; i < 5; i++ ) ss >> d[i] >> c; // stream the doubles out, each followed by a char
ss >> num; // stream the long long integer out
// Check data
cout << "\nDate: " << date;
cout << "\nDoubles: ";
for ( int i = 0; i < 5; i++ ) cout << fixed << setprecision( 6 ) << d[i] << " ";
cout << "\nLong long: " << num << "\n\n";
}
in.close();
}
You probably want to store the data from each line in a suitable struct, and the whole collection of these as a vector of those structs, but since I don't know what the numbers represent I'll just leave them as that.
There are some options. Choose one that seems easiest for you.
First option: read the whole line with getline, than replace all ',' with ' ' or '\t', create a stringstream with this line and use >> to read the values.
Second option: use getline to read date with separator ',' then read double with >> which terminates at ',' since you use '.' as decimal point then read the separator ',' and so on for all numerical values.