i have a .dat file that contains 30 lines where each line contains an ID number followed by 5 integers all of which are separated by unknown amount of white space characters.
example:
c123456 4 10 4 7 30
so far i have an array, string temporary[], and each element contains a different line of the .dat file. now i want to further seperate that string into different parts so i can store each part into it's own array.
example:
take each ID number and store it into ID[0], ID[1], etc then store the first int into num1[0], num1[1], etc and so forth.
any way to manipulate this string into separate parts or am i trying to tackle this problem from the wrong angle?
<iostream>
<fstream>
<string>
using namespace std;
//some variable and finction declaratiosn here...
myIn.open(filename.c_str());
while (myIn)
{
getline(myIn, temp);
temporary[i]=temp;
i++
}
so after that executes every subscript of temporary[] has a line of the file
i tried to just do
myIn>>idNo >> first >> second....etc
but that only read the first line of the file and i didn't know how to make it continue on to the remaining 29 lines. also tried taking the variable temp and doing:
temp>> idNo >> first >> second ....
but i get "no match for a >> operator" error as well as when i tried
temporary[0]>> idNo >> first >> second ...and so on
>but that only read the first line of the file and i didn't know how to make it continue on to the >remaining 29 lines. also tried taking the variable temp and doing:
using a while loop caused only the first array elements to be stored properly.
i tried using a sub string but of course only the ID number length is know so i was only able to separate out that part of the string. The amount of white space between the ID character and next integer is not known nor is if the integer is a single or double digit (6 or 16).