I need to read a .dat file that looks like this:
Atask1 Atask2 Atask3 Atask4 Atask5 Btask1 Btask2 Btask3 Btask4 Btask5 Ctask1 Ctask2 Ctask3 Ctask4 Ctask5 Dtask1 Dtask2 Dtask3 Dtask4 Dtask5
and I should be able to display information as follows:
cout << line(3) << endl; // required output shown below >>Ctask1 Ctask2 Ctask3 Ctask4 Ctask5 cout << line(2)(4) << endl; // required output shown below >>Btask4
I do not know how to read 1 line and split it into an array of 5 different lines. I would like the entire .dat file to be converted to a vector or list or some matrix / array structure for easy reference
any simple code or solutions for this ??
PLEASE, HELP?!?!?!?: -)
EDIT:
vector<string> dutyVec[5]; dut1.open(dutyFILE); if( !dut1.is_open() ){ cout << "Can't open file " << dutyFILE << endl; exit(1); } if(dut1.eof()){ cout << "Empty file - no duties" << endl; exit(1); } while ( !dut1.eof()){ int count = 0; getline(dut1, dutyVec[count]); count++; }
source share