The C++ Standard Library
- C++ Library - <valarray>
- C++ Library - <utility>
- C++ Library - <typeinfo>
- C++ Library - <tuple>
- C++ Library - <thread>
- C++ Library - <string>
- C++ Library - <stdexcept>
- C++ Library - <regex>
- C++ Library - <numeric>
- C++ Library - <new>
- C++ Library - <memory>
- C++ Library - <locale>
- C++ Library - <limits>
- C++ Library - <functional>
- C++ Library - <exception>
- C++ Library - <complex>
- C++ Library - <atomic>
- C++ Library - <streambuf>
- C++ Library - <sstream>
- C++ Library - <ostream>
- C++ Library - <istream>
- C++ Library - <iostream>
- C++ Library - <iosfwd>
- C++ Library - <ios>
- C++ Library - <iomanip>
- C++ Library - <fstream>
- C++ Library - Home
The C++ STL Library
- C++ Library - <iterator>
- C++ Library - <algorithm>
- C++ Library - <vector>
- C++ Library - <unordered_set>
- C++ Library - <unordered_map>
- C++ Library - <stack>
- C++ Library - <set>
- C++ Library - <queue>
- C++ Library - <map>
- C++ Library - <list>
- C++ Library - <forward_list>
- C++ Library - <deque>
- C++ Library - <bitset>
- C++ Library - <array>
C++ Programming Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
C++ Library - <fstream>
Introduction
This data type represents the file stream generally, and has the capabipties of both ofstream and ifstream which means it can create files, write information to files, and read information from files.
Definition
Below is definition of std::fstream.
template< class CharT, class Traits = std::char_traits<CharT>> class basic_fstream : pubpc std::basic_iostream<CharT, Traits>
Parameters
charT − Apased as member char_type.
traits − Apased as member traits_type.
Member types
Following member types can be used as parameters or return type by member functions.
Sr.No. | Member types | Definition |
---|---|---|
1 | char | Character Type |
2 | char_traits<char> | traits_type |
3 | int | const value_type |
4 | int | int_type |
5 | streampos | pos_type |
6 | streamoff | off_type |
Functions from <fstream>
Below is pst of all methods from <fstream>
Member functions
Sr.No. | Method & description |
---|---|
1 | Closes the file currently associated with the object, disassociating it from the stream. |
2 | Returns whether the stream is currently associated to a file. |
3 | Opens the file identified by argument filename, associating it with the stream object. |
4 | Returns a constant iterator which points to the start of the array. |
5 | Returns a pointer to the internal filebuf object. |
6 | Exchanges all internal data between x and *this. |
Non-member overloaded functions
Sr.No. | Method & description |
---|---|
1 | Exchanges the values of the fstream objects x and y. |