Incorrect logic flow? function that gets coordinates for a sudoku game
<p>This function of mine keeps on failing an autograder, I am trying to figure out if there is a problem with its logic flow? Any thoughts?</p>

<p>Basically, if the row is wrong, "invalid row" should be printed, and clearInput(); called, and return false. When y is wrong, "invalid column" printed, and clearInput(); called and return false.</p>

<p>When both are wrong, only "invalid row" is  to be printed (and still clearInput and return false.</p>

<p>Obviously when row and y are correct, print no error and return true.</p>

<p>My function gets through most of the test cases, but fails towards the end, I'm a little lost as to why.</p>

<pre><code>bool getCoords(int &amp; x, int &amp; y)
{
    char row;
    bool noError=true;

    cin&gt;&gt;row&gt;&gt;y;
    row=toupper(row);

    if(row&gt;='A' &amp;&amp; row&lt;='I' &amp;&amp; isalpha(row)  &amp;&amp; y&gt;=1 &amp;&amp; y&lt;=9)
    {   
        x=row-'A';
        y=y-1;  
        return true;
    }

    else if(!(row&gt;='A' &amp;&amp; row&lt;='I'))
    {
        cout&lt;&lt;"Invalid row"&lt;&lt;endl;
        noError=false;
        clearInput();
        return false;   
    }

    else
    {
       if(noError)  
       {
           cout&lt;&lt;"Invalid column"&lt;&lt;endl;
       }
       clearInput();
       return false;
    }
}
</code></pre>
