Defines a stream to be used to read single-byte character data serially from a file. ifstream is a typedef that specializes the template class basic_ifstream for char.

There is also wifstream, a typedef that specializes basic_ifstream to read wchar_t double-wide characters. For more information, see wifstream.


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


The type is a synonym for template class basic_ifstream, specialized for elements of type char with default character traits. An example is

using namespace std;

ifstream infile("existingtextfile.txt");

if (!infile.bad())


// Dump the contents of the file to cout.

cout << infile.rdbuf();




Header: <fstream>

Namespace: std

See Also

basic_ifstream Class
iostream Programming
iostreams Conventions