0

I have a file like this:

4 88 101

1 22 100

6 41 151

I have 3 arrays and i want to put the first values(4, 1, 6) to my first array, the second values(88, 22, 41) to my second array etc. So how can I split each line by space??

I have already read the file but I cannot fill my arrays with these values.

Business Man
  • 81
  • 1
  • 6

1 Answers1

0

If you know the exact number of items per line of data from the file, you can open it with an ifstream and do:

int firstNum, secondNum, thirdNum;

while (inFile >> firstNum >> secondNum >> thirdNum)
{
    //do something
}
m_callens
  • 6,100
  • 8
  • 32
  • 54