在codeblocks下的文件读写
来源:互联网 发布:淘宝店铺复制宝贝 编辑:程序博客网 时间:2024/06/14 09:19
在C++中的文件读写操作
#include <iostream>
#include <fstream>using namespace std;
int main()
{
int num[5];
ofstream outfile("t.txt",ios::out);
if(!outfile) //打开失败
{
cout<<"open error!"<<endl;
}
for(int i=0;i<5;++i)
{
cin>>num [i];
outfile<<num[i]<<endl;
}
outfile.close();
cout<<"文件写入完毕!!读出如下:"<<endl;
ifstream infile("t.txt",ios::in);//打开文件
if(!infile) //打开失败
{
cout<<"open error!"<<endl;
}
for(int i=0;i<5;++i)
{
infile>>num[i];
cout<<num[i]<<" ";
}
infile.close();
return 0;
}
与C语言中差不多,但有所区别,记得是ios::out!!!
- 在codeblocks下的文件读写
- CodeBlocks在win7+VS2010下的配置
- codeblocks在CENTOS下的编译安装
- 在Ubuntu下安装codeblocks
- codeblocks下如何修改新建文件的默认代码
- codeblocks下如何修改新建文件的默认代码?
- Boost库在CodeBlocks环境下的编译
- CodeBlocks在win7+Vs2010环境下的配置
- Boost库在CodeBlocks环境下的编译
- 在windows下codeblocks中配置pthread的库
- 在codeblocks环境下数组越界的问题
- Linux下的文件读写
- Android下的文件读写
- 在linux下设备文件读写实例
- JavaScript在IE下读写文件
- exit在codeblocks编译环境下在哪个头文件中声明
- web 工程下 java操作属性文件保存在classes下的读写操作
- ios 读写plist文件,在模拟器下可行,而在真机上不行的问题bug
- 关于:宏 (带参数的宏定义)
- go实现留言本
- uestc oj 1035 论文搜索
- POJ1041 John's trip
- 搭建 eclipse pydev python 开发环境 on mac and windows
- 在codeblocks下的文件读写
- 细说Cookie
- 用crtmpserver搭建开源rtmp直播服务
- div和span
- 每日一C------广播
- The fundamentals of Bash Scripting(Bash脚本编程基础)|nettusplus
- 用开源nginx-rtmp-module搭建flash直播环境
- php serialize序列化
- 内核proc文件系统与seq接口(1)---内核proc文件系统简介