C++语言 之 I/O

C++ I/O

1、Constructors:构造器

Fstream(const char *filename, openmode mode);

Ifstream(const char *filename, openmode mode);

Ofstream(const char *filename, openmode mode);

 

2、Bad():如果出现错误则返回true

Bool bad();

 

3、Clear():清除状态标志

Void clear(iostate flags = goodbit);

 

4、Close:关闭一个流

Void close();

 

5、Eof():如果处于文件结尾则返回true

bool eof();

 

6、Fail():如果出现错误则返回true

Bool fail();

 

7、Fill():控制默认填充字符

Char fill();

Char fill(char ch);

 

8、Flags():操作flags

Fmtflags flags();

Fmtflags(flags(fmtflags f);

 

9、Flush():清空缓冲区

Ostream &flush();

 

10、Gcount():返回读取的最后一次输入的字符数

Streamsize gcount();

 

11、Get():读取字符

Int get();

istream &get(char &ch);

Istream &get(char *buffer, streamsize num);

Istream &get(char *buffer, streamsize num, char delim);

Istream &get(streambuf &buffer);

Istream &get(streambuf &buffer, char delim);

 

12、Getline():读取一行字符

Istream &getline(char *buffer, streamsize num);

Istream &getline(char *buffer,streamsize num, char delim);

 

13、Good():如果没有出现过错误则返回true

Bool good();

 

14、Ignore():读取字符并忽略指定字符

Istream &ignore(streamsize num = 1, int delim=EOF);

 

15、Open():创建一个输入流

Void open(const char *filename);

Void open(const char *filename, openmode mode);

 

16、Peek():检查下一个输入的字符

Int peek();

 

17、Precision():设置精度

Streamsize precision();

Streamsize precision(streamsize p);

 

18、Put():写字符

Ostream &put(char ch);

 

19、Putback():返回字符给一个流

Istream &putback(char ch);

 

20、Rdstat():返回流的状态

Iostate rdstate();

 

21、Read():读取字条符

Istream &read(char *buffer, streamsize num);

 

22、Seekg():在一个输入流中进行随机访问

Istream &seekg(off_type offset, ios::seekdir origin);

Istream &seekg(pos_type position);

 

23、Seekp():在一个输出流中进行随机访问

Ostream &seekp(off_type offset, ios::seekdir origin);

Ostream &seekp(pos_type position);

 

 

24、Setf():设置格式标志

Fmtflags setf(fmtflags flags);

Fmtflags setf(fmtflags flags. Fmtflags needed);

 

 

25、Sync_with_stdio():同标准I/O同步

Static bool sync_with_stdio(bool sync = true);

 

26、Tellg():使用输入流读取流指针

Pos_type tellg();

 

27、Tellp():使用输出流读取流指针

Pos_type tellp();

 

28、Unsetf():清除格式标志

Void unsetf(fmtflags flags);

 

29、Width():操作域宽度

Int width();

Int width(int w);

 

30、Write():写字符

Ostream &write(const char *buffer, streamsize num);

 

 

猜你喜欢

转载自www.cnblogs.com/Miraclesl/p/9186339.html
今日推荐