ifstream

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search

ifstream is the C++ standard library class that provides an interface to read data from files as input streams.

To use the ifstream class, fstream library (header file) must be included using the preprocessor directive: #include <fstream>

The input stream may open a file in the constructor:

ifstream inf("input.dat", ifstream::in);

or afterwards:

ifstream inf; inf.open("input.dat");

To close a stream, one uses the close method: inf.close();

The ifstream destructor will close the file cleanly as well. It is perfectly acceptable to allow the ifstream object to fall out of scope without calling close. This is often a desirable style, as it simplifies the "clean up" process when an exception is thrown or an error is otherwise encountered.

References

de:C++-Standardbibliothek fr:C++ standard library vi:Thư viện chuẩn C++

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...