Okay, so i was trying to make this work.
Two queues need to be created using input from the user for 2 file names.
For some reason I get 1 queue, the first one filled. Then the second queue never has anything in it. Please help me with better code, or help me with this code. Thanks alot!

sample1:
2
3
4
-1

sample2:
4
5
6
-1
void WorkForce::MakeDoubleQueue()  {
char input1[256], input2[256];
	cout << "Please enter a name for input file ONE: ";
	     cin >> input1;
	
	ifstream myfile, openagain;
	myfile.open(input1);
	while (!myfile.eof())
	{
	int i;
	myfile >> i;
	q1.push (i);
	}
	myfile.close();
	//do the above again for input file TWO
	cout << "Please enter a name for input file TWO: ";
	     cin >> input2;
	openagain.open(input2);
	while (!openagain.eof())
	{
	int k;
	myfile >> k;
	q2.push (k);
	}
	openagain.close();
} //end of MakeDoubleQueue

Recommended Answers

All 4 Replies

Thankyou, that fixed it!

Since were on queues, is this a worthy working condition that will stop a queue when they empty? I want them both to be empty before it stops. Thanks.

while (!robot2000.q1.empty() || !robot2000.q2.empty() ) 
{
robot2000.reflexAgentWithState();
}

Test it and see if it works, but yes, that looks correct.

Thanks, everything works now.

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.