// instr3.cpp -- reading more than one word with get() & get()
#include <iostream>
int main()
{
using namespace std;
const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];
cout << "Enter your name:\n";
cin.get(name, ArSize); // read string, newline
cout << "Enter your favorite dessert:\n";
cin.clear();
cin.get(dessert, ArSize).get();
cout << "I have some delicious " << dessert;
cout << " for you, " << name << ".\n";
cin.get();
return 0;
}
cin.clear不是可以恢复get设置的失效位吗?
我理解的cin.clear相当于在cin,get(arraryName,arrarySize)后又加了一个.get(),我理解的这个多加的.get()其实是为了读取一个回车。
大伙可以告诉我我理解的那有错吗?