So I have the below code to check the input, I'm just having trouble because apparently flushing the input causes the tests (its an assignment) to lock up and I need to manually break out of it.

The problem is that if I remove the flushing of the input it it doesn't error out correctly.

i.e. instead of enterin rrrtrtere and it errors out once, it will error out 9 times.

This is the test data:

Test 3:
r4789kfdour49frkbjfds-r4tnjfdw0-ir4kljfdrwep943rpiofdkljfd04wpgenbp['er-=iohfgf$
ioufkljfdfdskljfpiofdsnmvfpkorekl,mfrksdveiouwefds piode
h2
v3
h-1
q
Code:
      if( dir== 'i')
      {
         print_instructions();
         continue;
      }
      else if( dir=='q')
      {
         break;
      }
      else
      {
         char p;
         cin>>p;
         const char * temp;

         temp= &p;
         rowcol= atoi(temp);
         if((dir=='h' && row<=1 && rowcol<=ROWS) 
            || (dir=='v' && col<=2 && rowcol<=COLS))
         {
            movePuzzle(puzzle, dir, rowcol);
            print_puzzle(puzzle);
            flag = is_winning_state(puzzle);
         }
         else
         {
            cin.ignore(1000,'\n');
            continue;
         }