std::basic_fstream<CharT,Traits>::close (3) - Linux Manuals
std::basic_fstream<CharT,Traits>::close: std::basic_fstream<CharT,Traits>::close
Command to display std::basic_fstream<CharT,Traits>::close
manual in Linux: $ man 3 std::basic_fstream<CharT,Traits>::close
NAME
std::basic_fstream<CharT,Traits>::close - std::basic_fstream<CharT,Traits>::close
Synopsis
void close();
Closes the associated file.
Effectively calls rdbuf()->close(). If an error occurs during operation, setstate(failbit) is called.
Parameters
(none)
Return value
(none)
Notes
This function is called by the destructor of basic_fstream when the stream object goes out of scope and is not usually invoked directly.
Example
// Run this code
#include <string>
#include <fstream>
#include <iostream>
int main()
{
std::fstream f1("example1", std::ios::out),
f2("example2", std::ios::out),
f3("example3", std::ios::out);
std::cout << std::boolalpha
<< f1.is_open() << '\n'
<< f2.is_open() << '\n'
<< f3.is_open() << '\n';
f1.close();
f2.close();
std::cout << f1.is_open() << '\n'
<< f2.is_open() << '\n'
<< f3.is_open() << '\n';
}
Possible output:
true
true
true
false
false
true
See also
checks if the stream has an associated file
is_open (public member function)
opens a file and associates it with the stream
open (public member function)
flushes the put area buffer and closes the associated file
close (public member function of std::basic_filebuf<CharT,Traits>)
Pages related to std::basic_fstream<CharT,Traits>::close
- std::basic_fstream<CharT,Traits>::basic_fstream (3) - std::basic_fstream<CharT,Traits>::basic_fstream
- std::basic_fstream<CharT,Traits>::is_open (3) - std::basic_fstream<CharT,Traits>::is_open
- std::basic_fstream<CharT,Traits>::open (3) - std::basic_fstream<CharT,Traits>::open
- std::basic_fstream<CharT,Traits>::operator= (3) - std::basic_fstream<CharT,Traits>::operator=
- std::basic_fstream<CharT,Traits>::rdbuf (3) - std::basic_fstream<CharT,Traits>::rdbuf
- std::basic_fstream<CharT,Traits>::swap (3) - std::basic_fstream<CharT,Traits>::swap
- std::basic_fstream (3) - std::basic_fstream
- std::basic_filebuf (3) - std::basic_filebuf
- std::basic_filebuf<CharT,Traits>::basic_filebuf (3) - std::basic_filebuf<CharT,Traits>::basic_filebuf
- std::basic_filebuf<CharT,Traits>::close (3) - std::basic_filebuf<CharT,Traits>::close
- std::basic_filebuf<CharT,Traits>::imbue (3) - std::basic_filebuf<CharT,Traits>::imbue
- std::basic_filebuf<CharT,Traits>::is_open (3) - std::basic_filebuf<CharT,Traits>::is_open
- std::basic_filebuf<CharT,Traits>::open (3) - std::basic_filebuf<CharT,Traits>::open
- std::basic_filebuf<CharT,Traits>::operator= (3) - std::basic_filebuf<CharT,Traits>::operator=
- std::basic_filebuf<CharT,Traits>::overflow (3) - std::basic_filebuf<CharT,Traits>::overflow
- std::basic_filebuf<CharT,Traits>::pbackfail (3) - std::basic_filebuf<CharT,Traits>::pbackfail