Unsure of the best method to use for transferring data from txt file.

So I have data on a txt file that looks like this...
SMALL BEANS
1 5
10000 10 10
5000 50 8
100 100 6
10 1000 4
1 10000 2

PIRATE'S BOOTY, ARRR
10 6
50000 20 0
10000 100 0
1000 500 0
100 2000 738
10 7500 2945
1 10000 4476

BIG MONEY HU$TLA$
20 7
1000000 10 7
500000 50 29
10000 100 78
1000 500 396
100 2000 1439
20 5000 3218
10 10000 6210

I am using getline(myfile, string) to get the the first line of the code.
My problem is I need the two numbers in each of the second lines under the title of the game (Small Beans, Pirates Booty, Big Money Hustla). So for the first game I need to somehow transfer the two numbers, 1 and 5 into an int array and need it to stop after it stores the 5. So I am thinking...
int array[80];

do
{
I am not sure what would go here...
Possibly getline function where getline(myfile, string) gets the second line, but how do I terminate it before it also "gets" the third line??
Also there would be two numbers in the string so converting it to an integer would give me just one integer, which is why I believe I should use an array which would allow me to use both integers

}
while(code gets two numbers (1, 5) in second line of each block of code)
Every call to getline() will only read 1 line.

Once you have the string, you need to split it based on the location of the " " space character. Once you know how many objects it splits in to you can then convert the necessary ones to int/unsigned
Topic archived. No new replies allowed.