清除缓存cin.sync()

/*清除缓存cin.sync();*/
#include <iostream>
using namespace std;
int main () {
  char first, second;

  cout << "Please, enter a word: ";
  first=cin.get();
  cin.sync();
  cout << "Please, enter another word: ";
  second=cin.get();

  cout << "The first word began by " << first << endl;
  cout << "The second word began by " << second << endl;

  return 0;
}
posted @ 2012-10-31 19:39  myth_HG  阅读(420)  评论(0编辑  收藏  举报