Reading text files with different information

Hello all,

I am working on a project that contains a text file that I need to be able to read and parse information from. The issue is that the text file contains two different type of information on adds to a queue or stack and the other removes from the queue or stack. I am trying to read the text file to determine if I need to add to stack or queue or remove form before said options. How would you write a function to read the file determine if I am adding an amount or removing from either source. I was thinking of a splitter method but realized if I am popping or serving there is no information in second part of the split.
Example input is as follows:

append 10
serve
append 20
append 30
serve
push 10
push 50
push 20
push 20
pop
push 50
pop
pop
append 50
append 35
append 25
append 40
serve
append 60
append 70
append 75
append 100
append 200
append 150
push 10
push 50
pop
pop
push 20
push 20
push 10
pop
pop
push 10
push 50
push 20
push 20
push 10
pop
pop
push 20
push 20
push 10
pop
pop
push 20
push 10


any help would be appreciated
What have you tried?

I'd start by reading a line into a std::string, parse that string into a std::string and a number, check the string against your keywords and take the appropriate action.

Topic archived. No new replies allowed.