相关文章推荐
坐怀不乱的生菜  ·  文件流(fstream, ...·  1 周前    · 
聪明伶俐的橡皮擦  ·  Learn about ...·  1 年前    · 
傻傻的毛豆  ·  mongod failed to open ...·  2 年前    · 
知识渊博的打火机  ·  python numpy 保存 ...·  2 年前    · 

在看

C++

编程思想中,每个练习基本都是使用

ofstream,ifstream,fstream

,以前粗略知道其

用法和含义,在看了几位大牛的博文后,进行整理和总结:

这里主要是讨论

fstream

的内容:

[java]

view plaincopyprint?

1.

#include <fstream>

2.

ofstream         //

文件写操作

内存写入存储设备

3.

ifstream         //

文件读操作,存储设备读区到内存中

4.

fstream          //

读写操作,对打开的文件可进行读写操作

1.

打开文件

fstream

类中,

成员函数

open

()

实现打开文件的操作,

从而将数据流和文件进行关联,

通过

ofstream,ifstream,fstream

对象进行对文件的读写操作

函数:

open

()

[cpp]

view plaincopyprint?

1.

<span style="font-family: Times New Roman; font-size: 16px;">

2.

public member function

3.

4.

void open ( const

char

* filename,

5.

ios_base::openmode mode = ios_base::in | ios_base::out );

6.

7.

void open(const

wchar_t

*_Filename,

8.

ios_base::openmode mode= ios_base::in | ios_base::out,

9.

int

prot = ios_base::_Openprot)

10.

11.

</span>