std::ios_base:: openmode
|
typedef
/* implementation defined */
openmode
;
|
||
|
static
constexpr
openmode app
=
/* implementation defined */
;
static
constexpr
openmode binary
=
/* implementation defined */
;
|
||
|
static
constexpr
openmode noreplace
=
/* implementation defined */
;
|
(C++23 이후) | |
사용 가능한 파일 열기 플래그를 지정합니다. 이것은 BitmaskType 입니다. 다음 상수들이 정의되어 있습니다:
| 상수 | 설명 |
| app | 각 쓰기 전에 스트림 끝으로 이동 |
| binary | 바이너리 모드 로 열기 |
| in | 읽기용으로 열기 |
| out | 쓰기용으로 열기 |
| trunc | 열 때 스트림 내용 삭제 |
| ate | 열기 직후 스트림 끝으로 이동 |
| noreplace (C++23) | 배타 모드로 열기 |
예제
#include <fstream> #include <iostream> #include <string> int main() { const char* fname = "unique_name.txt"; // 임시 스트림 객체에 쓰기 std::fstream(fname, std::ios::out | std::ios::trunc) << "Hi"; std::string s; std::fstream(fname, std::ios::in) >> s; std::cout << s << '\n'; }
출력:
Hi
참고 항목
|
파일을 열고 연결된 문자 시퀀스로 구성합니다
(
std::basic_filebuf<CharT,Traits>
의 public member function)
|
|
basic_stringbuf
객체를 생성합니다
(
std::basic_stringbuf<CharT,Traits,Allocator>
의 public member function)
|