I have the following code.
           int x1, x2;
           char check[3];
           do{
                //input should be (x1,x2)
                successfully_inputed = scanf("(%d,%d%2s", &x1, &x2, check);
                if(successfully_inputed == EOF)
                        break;
                if(check[1] || successfully_inputed != 3 || check[0] != ')'){
                        fprintf(stderr, "Invalid line");
                        
                        char ch;
                        while((ch = getchar()) != EOF && ch != '\n');
                        continue;
                }
                getchar(); // remove the new line character from buffer
          }while(1);
It does work for every input i give other than a particular one. When i give anything and then followed by the EOF, for example "asdEOF" then it consumes "asd" and when it reaches EOF it asks me for input, not the scanf() but the getchar(). Why is this happening and how can i solve it?
 
    