I need to make such a check that the user enters only a value, if he enters a letter, or just some character without a number, then display an error message and enter a new value. For example, the input is "3.00", the output is "Invalid value! Please try again"
I want to understand how to do this, otherwise I did not find any information on the Internet
#include <iostream>
#include <cmath>
using namespace std;
long long byaka(long long a, long long b, long long& k, long long& w)
{
if (b == 0)
{
k = 1;
w = 0;
return a;
}
long long d = byaka(b, a % b, k, w);
k -= (a / b) * w;
swap(k, w);
return d;
}
int main()
{
long long a, b, c, k, w, d;
cout << "A B C: \n";
cin >> a >> b >> c;
d = byaka(a, b, k, w);
while (c % d != 0)
{
cout << "Impossible! Vvedite A B C: \n";
cin >> a >> b >> c;
d = byaka(a, b, k, w);
}
long long t = c / d * k, t2 = b / d;
if (t == 0) cout << 0 << " " << c / d * w;
if (t > 0) cout << t + t2 * (-(t / t2)) << " " << c / d * w - a / d * (-(t / t2));
if (t < 0) cout << t + t2 * (-((t - t2 + 1) / t2)) << " " << c / d * w - a / d * ((-((t - t2 + 1) / t2)));
}