The input looks like this:

Start 0
Run 40
Disk 0
Run 20
End

Each word and number means something. The number is the time and the word a command. What's the best way to loop through it and evaluate it? So it's 2 different elements per line that should evaluated seperately. Any ideas?

Recommended Answers

All 2 Replies

There are probably lots of ways to do it, but I would start out with a structure that contains two items: command and count. Then put the structure in an array or linked list. Once that is done it can be evaluated in a loop by iterating through the array or linked list.

The input is already being read by a linked list. I think I will put it into a queue...

struct Input_Table
{
    string p_num;       //process number
    string operation;   // word
    int parameter;
};

then I do:

queue<Input_Table> q;
Input_Table test, test2...

So, something like this? And you can loop through it once it's been put into the queue. A queue because there are many segments and each segment can be put into the queue and then get searched by the loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.