首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::basic_ofstream::open

void open( const char *filename, ios_base::openmode mode = ios_base::out );

(1)

?

void open( const std::filesystem::path::value_type *filename, ios_base::openmode mode = ios_base::out );

(2)

(since C++17)

void open( const std::string &filename, ios_base::openmode mode = ios_base::out );

(3)

(since C++11)

void open( const std::filesystem::path &filename, ios_base::openmode mode = ios_base::out );

(4)

(since C++17)

打开文件并将其与名称关联。filename文件流。

打电话setstate(failbit)在失败的时候。

Calls clear() on success.

(since C++11)

1-2%29有效呼叫rdbuf()->open(filename, mode | ios_base::out).%28见std::basic_filebuf::open有关调用%29的效果的详细信息。仅在下列情况下才提供过载%282%29std::filesystem::path::value_type不是char.%28自C++17%29

3-4%29有效调用%281-2%29open(filename.c_str(), mode)...

参数

filename

-

the name of the file to be opened

mode

-

specifies stream open mode. It is bitmask type, the following constants are defined: Constant Explanation app seek to the end of stream before each write binary open in binary mode in open for reading out open for writing trunc discard the contents of the stream when opening ate seek to the end of stream immediately after open

Constant

Explanation

app

seek to the end of stream before each write

binary

open in binary mode

in

open for reading

out

open for writing

trunc

discard the contents of the stream when opening

ate

seek to the end of stream immediately after open

Constant

Explanation

app

seek to the end of stream before each write

binary

open in binary mode

in

open for reading

out

open for writing

trunc

discard the contents of the stream when opening

ate

seek to the end of stream immediately after open

返回值

%280%29

另见

is_open

checks if the stream has an associated file (public member function)

close

closes the associated file (public member function)

open

opens a file and configures it as the associated character sequence (public member function of std::basic_filebuf)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com