在一个程序中,我读取了一个 unsigned long long,这通常可以正常工作。但是,如果有人决定输入负数,则提示将无限打印。
这是我的代码的一部分,它是相关的:
unsigned long long betAmount = 0;
cout << "You have " << chipCount << " chips currently!" << endl;
cout << "How many chips would you like to bet?" << endl;
cout << "Must be a whole number: ";
cin >> betAmount;
这是相当标准的,除非给出否定的。