std::basic_fstream<CharT,Traits>:: close
From cppreference.net
<
cpp
|
io
|
basic fstream
|
void
close
(
)
;
|
||
관련 파일을 닫습니다.
rdbuf()->close() 를 효과적으로 호출합니다. 작업 중 오류가 발생하면, setstate ( failbit ) 가 호출됩니다.
목차 |
매개변수
(없음)
반환값
(없음)
참고 사항
이 함수는 스트림 객체가 범위를 벗어날 때
basic_fstream
의 소멸자에 의해 호출되며, 일반적으로 직접 호출되지 않습니다.
예제
이 코드 실행
#include <fstream> #include <iostream> #include <string> 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'; }
가능한 출력:
true true true false false true
참고 항목
|
스트림에 연결된 파일이 있는지 확인합니다
(public member function) |
|
|
파일을 열고 스트림과 연결합니다
(public member function) |
|
|
put 영역 버퍼를 비우고 연결된 파일을 닫습니다
(public member function of
std::basic_filebuf<CharT,Traits>
)
|