ifstream

定義要用來以序列方式從檔案中讀取單一位元組字元資料流。ifstream是,專長於樣板類別 typedef basic_ifstream的char。

另外還有wifstream,專門負責的 typedef basic_ifstream讀取wchar_t雙全的字元。如需詳細資訊,請參閱 wifstream

typedef basic_ifstream<char, char_traits<char> > ifstream;

備註

型別就是樣板類別的basic_ifstream、 特定項目的型別字元,使用預設字元特性。例子之一是

using namespace std;

ifstream infile("existingtextfile.txt");

if (!infile.bad())

{

// Dump the contents of the file to cout.

cout << infile.rdbuf();

infile.close();

}

需求

標頭: <fstream>

Namespace: 標準

請參閱

參考

basic_ifstream Class

iostream 程式設計

iostreams 慣例

其他資源

basic_ifstream 成員

<fstream> 成員