I have a problem with function which gets coordinates, from user, equal or bigger than 0 and lower than certain value M (M, x, y are ints). When I put only itegers everything is fine, but when i type two or one char my loop goes to infinity without asking to type again these coordinates.
My code:
 do {
        cout << "\t" << "Give coordinates in following format: X Y." << endl;
        cout << "\t";
        cin >> y >> x;
    } while (x < 0 || x > M || y < 0 || y > M);
 
    