c++io

父类函数 一般使用虚函数
析构函数也写成虚函数


#include <iostream>
using namespace std;
//输出缓冲遇到换行 有输入 满 程序结束 flush会刷新
int main()
{
cout<<"Hello";//缓冲 可以重定向
cerr<<"World";//无缓冲 不可重定向
clog<<"Tarena";//理论上缓冲 不可重定向 
}
                                                                        class ios


                                           /                                                                  \
                            iotream(cin)                                          ostream(cout cerr clog)
                  /                           \                        \                                          /            \                        \
 ifstream(文件流对象)  istringstream(字符串流对象)   iostram    ostrinstream  ofstream
                              /
                        fstream


#include <iostream>
using namespace std;
//非格式化得输出: i.get i.put i.getline() i.ignore()
//i.putback i.peek 
int main()
{
//EOF;//超越文件末尾 文件结束符
int n = cin.get();//返回ascii码 不会跳过空格 类似scanf("%c",&ch)和getchat
char c,d,e;
cin.get(c).get(d).get(e);//istream& get(char& ch)
cout<<n<<','<<c<<','<<d<<','<<e<<endl;
cout<<"===================="<<endl;
cout.put(n).put(c).put(d).put(e);
cin.ignore(200,'\n');//抛去输入缓冲区的字符最多清除200个字符 清除到换行为止
char ch;
cin>>ch;//跳过空白字符  类似scanf(" %c",&ch)
cout<<" ch= "<<ch<<endl;
}




#include <iostream>
using namespace std;
//非格式化得输出: i.get i.put i.getline() i.ignore()
//i.putback i.peek 
int main()
{
//io对象要求能转换成bool值 对处于正常状态io对象转成true 反之false
cout<<"cin = "<<cin<<endl;
cout<<"cout = "<<cout<<endl;
int n;
cin>>n;
cout<<"cin = "<<cin<<endl;
cout<<&cin<<endl;
cout<<&cout<<endl;
}


#include <iostream>
#include<string>
using namespace std;
//  非格式化输入
//  i对象.getline(char,数组大小) 不能读完一整行io设置错误状态
//  getline(i对象,string&)
//  都可以用第三参数指定读到那个字符停止 默认换行
int main()
{
char buf[10];
if(!cin.getline(buf,sizeof(buf))){
cout<<"行超长度"<<endl;
cin.clear();
cin.ignore();
}
cout<<"buf="<<buf<<endl;
string s;
getline(cin,s,'~');//到~为止
cout<<"s="<<s<<endl;
sprintf("%s",s.c_str());
system("pause");
}


#include <iostream>
#include<string>
using namespace std;
//i.putback()
//i.peek() 偷看
//i.
int main()
{
char buf[100];
cin>>ws;//跳过空白字符
char c = cin.get();
/*if(cin.get()>='0'&&cin.get()<='9')
cin.get();*///不能这么写会被调用3次
cin.putback(c);//退回
if(isdigit(c)){
double d;
cin>>d;
cout<<"d="<<d<<endl;
}
else{
string s;
cin>>s;
cout<<s<<endl;
}


//cin.peek();//查看不取走 返回ascii码
if(cin.peek()=='0'&&cin.peek()=='9'){
double w;

cin>>ws>>w;
cout<<w;
}
system("pause");
}




#include <iostream>
#include<string>
#include<sstream>
using namespace std;
class Point{
int x;
int y;
public:
Point(int x,int y):x(x),y(y)
{}
friend ostream& operator<<(ostream& os,const Point& p){
os<<'('<<p.x<<','<<p.y<<')'<<endl;
return os;
}
};
int main()
{
string s="12345 6.78 x hello 234 100";
istringstream is(s);
int a,b,c;
double d;
char e;
char buf[100];
is>>a>>d>>e>>buf>>oct>>b>>hex>>c;
ostringstream os;
Point p(3,5);
os<<"a="<<a<<",b="<<b<<",c="<<c<<",d="
<<d<<",e="<<e<<",buf="<<buf<<"p="<<p<<endl;
//将这些东西合并成了一个字符串?(不太确定)
cout<<"====="<<endl;
cout<<os.str()<<endl;//输出里面的字符串
cout<<os.str()[8];
system("pause");
}


#include <iostream>
#include<string>
#include<sstream>
#include<fstream>
using namespace std;


int main()
{
string path = "lianxi.cpp";
ifstream fin(path.c_str());
ofstream fout("06PM_1.cpp");//原有内容被清空
//等同于fin.open(path.c_str);
if(!fin) {cout<<"打开fin失败"<<endl;return 1;}//return表示失败了
if(!fout) {cout<<"打开fout失败"<<endl;return 1;}
char ch;
//while(ch = fin.get()!=EOF)
while(fin.get(ch)){
cout<<ch; fout<<ch;
}
// while(fin>>ch) cout<<ch;跳过所有的空白和换行
// while(fin){fin.get(ch);fout<<ch;}//会多出一个字符 
fin.close();
fout.close();
system("pause");
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的纺织品企业财务管理系统,源码+数据库+毕业论文+视频演示 在如今社会上,关于信息上面的处理,没有任何一个企业或者个人会忽视,如何让信息急速传递,并且归档储存查询,采用之前的纸张记录模式已经不符合当前使用要求了。所以,对纺织品企业财务信息管理的提升,也为了对纺织品企业财务信息进行更好的维护,纺织品企业财务管理系统的出现就变得水到渠成不可缺少。通过对纺织品企业财务管理系统的开发,不仅仅可以学以致用,让学到的知识变成成果出现,也强化了知识记忆,扩大了知识储备,是提升自我的一种很好的方法。通过具体的开发,对整个软件开发的过程熟练掌握,不论是前期的设计,还是后续的编码测试,都有了很深刻的认知。 纺织品企业财务管理系统通过MySQL数据库与Spring Boot框架进行开发,纺织品企业财务管理系统能够实现对财务人员,员工,收费信息,支出信息,薪资信息,留言信息,报销信息等信息的管理。 通过纺织品企业财务管理系统对相关信息的处理,让信息处理变的更加的系统,更加的规范,这是一个必然的结果。已经处理好的信息,不管是用来查找,还是分析,在效率上都会成倍的提高,让计算机变得更加符合生产需要,变成人们不可缺少的一种信息处理工具,实现了绿色办公,节省社会资源,为环境保护也做了力所能及的贡献。 关键字:纺织品企业财务管理系统,薪资信息,报销信息;SpringBoot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值