cplusplus
.com
教程
參考
文章
論壇
C++
教程
參考
文章
論壇
參考
C 庫
<cassert> (assert.h)
<cctype> (ctype.h)
<cerrno> (errno.h)
C++11
<cfenv> (fenv.h)
<cfloat> (float.h)
C++11
<cinttypes> (inttypes.h)
<ciso646> (iso646.h)
<climits> (limits.h)
<clocale> (locale.h)
<cmath> (math.h)
<csetjmp> (setjmp.h)
<csignal> (signal.h)
<cstdarg> (stdarg.h)
C++11
<cstdbool> (stdbool.h)
<cstddef> (stddef.h)
C++11
<cstdint> (stdint.h)
<cstdio> (stdio.h)
<cstdlib> (stdlib.h)
<cstring> (string.h)
C++11
<ctgmath> (tgmath.h)
<ctime> (time.h)
C++11
<cuchar> (uchar.h)
<cwchar> (wchar.h)
<cwctype> (wctype.h)
容器
C++11
<array>
<deque>
C++11
<forward_list>
<list>
<map>
<queue>
<set>
<stack>
C++11
<unordered_map>
C++11
<unordered_set>
<vector>
輸入/輸出
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>
多執行緒
C++11
<atomic>
C++11
<condition_variable>
C++11
<future>
C++11
<mutex>
C++11
<thread>
其他
<algorithm>
<bitset>
C++11
<chrono>
C++11
<codecvt>
<complex>
<exception>
<functional>
C++11
<initializer_list>
<iterator>
<limits>
<locale>
<memory>
<new>
<numeric>
C++11
<random>
C++11
<ratio>
C++11
<regex>
<stdexcept>
<string>
C++11
<system_error>
C++11
<tuple>
C++11
<type_traits>
C++11
<typeindex>
<typeinfo>
<utility>
<valarray>
<iostream>
物件
、cerr
cin
、clog
、cout
、wcerr
wcin
、wclog
、wcout
參考
<iostream>
cin
物件
<iostream>
std::
cin
extern istream cin;
標準輸入流
istream
類的物件,表示面向窄字元(
char
型別)的
標準輸入流
。它對應於
C 流
stdin
。
標準輸入流
是由環境決定的字元源。通常假定為來自外部源的輸入,例如鍵盤或檔案。
作為一個
istream
類的物件,可以使用提取運算子 (
operator>>
) 以格式化資料的形式檢索字元,也可以使用成員函式(如
read
)以非格式化資料的形式檢索字元。
該物件在標頭檔案
<iostream>
中宣告,具有
外部連結
和
靜態儲存期
:它在程式的整個生命週期內都存在。
在
靜態初始化順序
方面,保證
cin
在首次構造
ios_base::Init
型別的物件時或之前被正確構造和初始化。
在
靜態初始化順序
方面,保證
cin
在首次構造
ios_base::Init
型別的物件時或之前被正確構造和初始化,包含
<iostream>
至少算作對一個具有
靜態持續時間
的此類物件的一次初始化。
cin
與標準輸出流
cout
繫結
(見
ios::tie
),這表示在對
cin
執行每個 I/O 操作之前,
cout
的緩衝區會被
重新整理
(見
ostream::flush
)。
預設情況下,
cin
與
stdin
同步(見
ios_base::sync_with_stdio
)。
程式不應將對
cin
的輸入操作與對
wcin
的輸入操作(或與對
stdin
的其他寬定向輸入操作)混合使用:一旦對其中任一者執行了輸入操作,
標準輸入流
就會獲得一種朝向(
窄
或
寬
),只有透過在
stdin
上呼叫
freopen
才能安全地更改該朝向。
有關
cin
所支援操作的更多資訊,請參閱其型別
istream
的參考。
另見
istream
輸入流
(類)
、cout
標準輸出流
(物件)
wcin
標準輸入流 (寬)
(物件)