我以前在 C++ 中使用过 clear 函数,但我不知道它在 C 中是如何工作的。
我在某处读到 C 不知道屏幕并且 C 中不存在 clear 函数。是否有另一种翻译方法?
如果 .clear
和 .fail
函数不存在:
最后的问题:cin.fail
和cin.clear
还有cin.ignore
用C怎么写?
int main(){
int n;
cout << "Please enter number shapes to check: ";
cin >> n;
while(cin.fail() || n<1) {
cout << "Your number of shapes is invalid. " << endl;
cin.clear();
cin.ignore(256,'\n');
cout << "Enter the number of shapes to check: ";
cin >> n;
最佳答案
关于c++ - 有没有办法将 cin.fail 和 cin.clear 翻译成 C 编程语言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47022288/