回覆列表
  • 1 # 多樣人生

    這個是用來清空cin緩衝區裡面未讀取的資訊...

    例子:

    #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;

    }

    樣例輸入:

    you

    me

    樣例輸出:

    The first word began by y

    The second word began by m

  • 中秋節和大豐收的關聯?
  • 九五年農曆七月初五是什麼星座?