title: How to solve this infinite loop (do while loop)?
body: <p>Here is my code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;cctype&gt;
  using namespace std;
  
  int main()
  {
      char c_row;
      int col;
  
      do{
          cout &lt;&lt; "Enter the starting coordinates: ";
          cin &gt;&gt; c_row &gt;&gt; col;
          cin.ignore();
          cout &lt;&lt; endl;
      }
      while(!(toupper(c_row) &gt;='A' &amp;&amp; toupper(c_row) &lt;= 'J') ||
             !(col&gt;=1 &amp;&amp; col &lt;= 10) );
  
      cout &lt;&lt; "right input !!" &lt;&lt; endl; 
  
      return 0;
  }
  </code></pre>
  
  <p>I want to ask the user to input a coordinate on the below graph (a graph with row = A to J, col = 1 to 10). If the user enters the wrong input, the program will ask again until the user enter the right input.</p>
  
  <p><a href="https://i.stack.imgur.com/6FiVP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6FiVP.png" alt="the graph image"></a></p>
  
  <p>It works when invalid input is like "z11", "A0", "31241".</p>
  
  <p><a href="https://i.stack.imgur.com/lnK5g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lnK5g.png" alt="the output with these input"></a></p>
  
  <p>But it will cause an infinite loop when the invalid input is like "8z", "uu", "abcde".</p>
  
  <p><a href="https://i.stack.imgur.com/HwrmQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HwrmQ.png" alt="the output with these input"></a></p>
  
  <p>How can I solve this problem, and why does it happen?</p>