First of all I know the question title is not clear, thus, let me explain my issue.
I am writing a cpp code where I use std::cin, it is supposed to check if the input is or is not a number and if it is negative or positive.
Here is my code:
#include <windows.h>
#include <iostream>
using namespace std;
int main(void) {
SetConsoleTitle(" ");
while(true) {
int x;
if((cin >> x)) {
cin.ignore();
if(x > 0) {
cout << "Podmienka splnena\n";
}else{
cout << "Podmienka nesplnena\n";
}
}else{
cin.ignore();
cout << "Neplatny vstup\n";
}
}
}
The issue I am having is that it seems that cin does not accept any new input in case the input was not a number, which is pretty odd, what happens is that it will keep going on and on with the previous input, I hope I was pretty clear.