📜  整数类型验证 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:49.430000             🧑  作者: Mango

代码示例1
cout << endl << "Introduce an integer: ";
p = scanf("%d", &x);       //Scanf returns a false when the value doesn't match the correct format.
getchar();

while (p == false)
{   cout << endl << "You didn't introduce an integger. Try again.";

     cout << endl << "Introduce an integer: ";

    p = scanf("%d", &x);
      getchar();
}