Note that there are some explanatory texts on larger screens.

plurals
  1. POprinting queues in a specific order
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/12740900/outputting-queues-in-correct-order">outputting queues in correct order</a> </p> </blockquote> <p>I have two queues containing digits, integerQueue contains integers only, realQueue contains the beginning '.' then the following digits.</p> <p>i need to print out the integer queue if only integers have been read in but if realqueue has data in it, i need to print out the first half integerqueu then the second half realqueu to make a real number like 123.234</p> <p>currently my code will print real 1. then it will print integer: 2342343</p> <p>How can i fix this so that the correct output is displayed?</p> <pre><code>//if the realQueue is empty, then we just read in an integer, currentState must be 1, in order to print integer if(realQueue.empty() || currentState == '1')//implementation of the FSM { writeFile &lt;&lt;"Integer: "; while(!integerQueue.empty()) { writeFile &lt;&lt;integerQueue.front(); integerQueue.pop(); } } //since the realQueue has values in it, then it must bea real Number else { //currentState = '2'; // currentState must be == '2', since we have a real number to print writeFile&lt;&lt;"Real: "; //currentState has to be in real mode for it to print out to file /*while(!integerQueue.empty() &amp;&amp; currentState == '2') { writeFile &lt;&lt;integerQueue.front(); integerQueue.pop(); }*/ // currentState has to be in real mode for it to print out to file while(!realQueue.empty() &amp;&amp; currentState == '2' &amp;&amp; !integerQueue.empty()) { writeFile &lt;&lt;integerQueue.front()&lt;&lt;realQueue.front(); integerQueue.pop(); realQueue.pop(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload