c13
来源:互联网 发布:知豆电动汽车电池质保 编辑:程序博客网 时间:2024/06/03 18:02
1.fin.gcount();读取到的字节数
2.fin.read((char*)地址, 字节数); 不会自动加'\0'
3.fin.eof();是否读到文件末尾,end of file
4.width(1),指定小时按实际宽度输出,一次性,只对下一个输出有效
5.fill('*');永久有效:cout.width(10); cout.fill('*'); cout<<123<<endl;
6.输出格式控制符:cout<<wf(10, '*')<<100<<endl;
#include <iostream>#include <fstream>#include <string>using namespace std;class wf{int w;char f;public:wf(int w, char f):w(w), f(f){}friend ostream& operator<<(ostream&, const wf&);};ostream& operator<<(ostream& os, const wf& w){os.width(w.w);os.fill(w.f);return os;}int main(){cout<<wf(10, '*')<<100<<endl;system("pause");return 0;}
7.cout.precision(8);控制精度,最后一位四舍五入
8.cout.setf(ios::left); right, dec(10), oct(8), hex(16), showbase(前缀),showpoint(总是带小数点), uppercase(大写0X, A-F, E), showpos(positire带符号),scientific(科学计数法5.168E-6)
9.cout默认6位输出
10.cout.precision(2); cout.setf(ios::fixed); 小数点后精度
11.unsetf(ios::xx); 取消设置
12.使用cout.set(ios::hex),要cout.unsetf(ios::dec|ios::oct);
13.endl = \n + flush;cout<<flush;
14. 格式控制符都可以使用cout<<oct|dec|hex<<i<<endl;
15.格式控制函数对应的格式控制符<iosmanip> cout<<setw(宽度); cout<<setfill('*'); cout<<setprecision(8);
16.ofstream.fout(filename); 默认清除文件中的原有内容
17.fout(filename, ios::out(默认-写));可用ios::app追加,ios::binary二进制打开文件
18.win中以文本方式打开文件而不是二进制打开文件时,写'\n'时改为'\r''\n',读到'\r''\n'时改为'\n'。
19.fout.seekp(位置int);写put。fin.seekg(位置int);读get。
20.取得当前读位置fin.tellg();当前写位置fout.tellp();
21.读写打开文件fstream fio(filename, ios::in|ios::out|ios::binary);类继承关系 istream->ifstream, ostream->ofstream, istream/ostream->iostream->fstream。
22.内部类:成员内部类、局部内部类,作用域有限。①隐藏名字,避免类名冲突②通过提供统一内部类名来统一各个类的操作方法
23.成员内部类使用:
class A{public: class B{};};int main(){ A::B b;}
24.try{throw 变量;} catch(变量类型){} catch (变量类型){}
25.如果没有catch能够处理,退出不处理后面内容
26.catch(...){}接收任何类型
27.typedef int T; struct Node{T date; Node *next;};
28.基本类型() = 0;
- c13
- C13(IO)
- PE reading C13
- C13、Windows的内存结构
- C++程序设计语言读书笔记-C13 - 模版
- <PY><core python programming笔记>C13 面向对象编程
- 内置锁和显式锁的区别--JCIP C13读书笔记
- 程序员面试宝典 C13数据结构基础 13.1 单链表
- <c语言经典100例>c13 条件运算符
- 【备注】【C13】《Java从入门到精通(实例版)》PDF 书籍
- 用zxing 识别二维码的main函数
- combobox 中文首字母检索功能
- 浅谈ANR及如何分析解决ANR(2)
- 重温struts2之类型转换
- quick-cocos2d-x图片资源加密 (转)
- c13
- Leetcode_permutation-sequence(c++ and python version)
- 设计模式之适配器模式&外观模式
- 浅谈ANR及如何分析解决ANR(3)
- 对话框
- EXPORT_SYMBOL宏
- 又一HTML编辑器Simditor
- 数据结构——bitmap
- 黑马程序员笔记——Java基础