等效於:

#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
 
namespace std { 
    extern istream cin;
    extern ostream cout;
    extern ostream cerr;
    extern ostream clog;
 
    extern  wistream wcin;
    extern  wostream wcout;
    extern  wostream wcerr;
    extern  wostream wclog; 
}

使用cin輸入數據時,前導的空白符(whitespace)與後綴的空白符均被忽略。如果需要讀入使用這些空白符,用get()函數返回輸入流對象的下一個字符。peek()函數返回輸入流對象的下一個字符,但並不把它從輸入流中拋棄。putback()函數把一個字符放回輸入流對象的下一個字符位置。

用getline()從輸入流的當前位置讀入所有字符(包含前導空白符),直至遇到回車符(從流中拋掉)為止,保存在string變量中;截至字符也可以指定。

fail()函數用來檢查流對象上一個操作是否成功。clear()用來清除流對象的剛剛的失敗標誌。

eof()函數檢查輸入流對象是否到了文件底部。

cin.ignore(N,ch)忽略(讀並拋棄)N個字符,或者直至遇到ch字符為止。

manipulator是控制輸入輸出格式的對象,包括:

  • endl
  • flush

為了在條件表達式里使用流對象,IOStream library重載了兩個操作符void *和!。其中類型強制轉換運算符void *用來測試如 if (stream object) ,運算符!用於測試如 if (!(stream object))