C++读写初步
来源:互联网 发布:jquery怎么做分页java 编辑:程序博客网 时间:2024/06/08 18:14
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
/*ifstream in("E:\testfile\test.txt");//声明一个输入文件流 in,并默认调用.open()函数与文件关联
//判断输入流是否与文件关联
if (!in.is_open())
{
cout << "the file can't be opened" << endl;
exit(1);//终止程序
}
while (!in.eof())//未到文件数据末尾时
{
char text[20];
in.getline(text, 10);
cout << text << endl;
}
in.close();*/
//******************************
ofstream out;//声明一个输出流 out
out.open("E:\\testfile\\test.txt",ofstream::app);//与文件关联,第二参数注意
//判断是否关联上了
if (!out.is_open())
{
cout << "can't write into the file";
exit(1);
}
out << "\nthe file can be writed.\n";
out.close();
return 0;
}
#include <fstream>
using namespace std;
int main()
{
/*ifstream in("E:\testfile\test.txt");//声明一个输入文件流 in,并默认调用.open()函数与文件关联
//判断输入流是否与文件关联
if (!in.is_open())
{
cout << "the file can't be opened" << endl;
exit(1);//终止程序
}
while (!in.eof())//未到文件数据末尾时
{
char text[20];
in.getline(text, 10);
cout << text << endl;
}
in.close();*/
//******************************
ofstream out;//声明一个输出流 out
out.open("E:\\testfile\\test.txt",ofstream::app);//与文件关联,第二参数注意
//判断是否关联上了
if (!out.is_open())
{
cout << "can't write into the file";
exit(1);
}
out << "\nthe file can be writed.\n";
out.close();
return 0;
}
0 0
- WDM初步--端口读写
- C++读写初步
- 关于VC,C语言 汉字(GB2312)读写的一些初步探索
- Turbo C 程序设计初步
- Linux C 初步(1)
- C bulider计算器初步
- C++Boost 初步了解
- 初步认识C语言
- C编译初步
- Objective-C初步
- C语言+正则初步
- Objective-C 初步学习
- c extern初步了解
- C语言初步总结
- C语言模块化初步
- QP/C初步入门
- 【初步了解】C#-Socket
- C++__程序设计初步
- Hibernate映射 --- 自身跟自身的一对多关联
- iOS nil, Nil, NSNull NULL的区别
- win7系统ActiveMQ安装后,提示端口被占用无法启动问题
- 转做大系统硬件
- 列表ListView控件的使用
- C++读写初步
- XRay5
- next-key lock (glap lock)完全解析.
- Android学习笔记32:滑屏控件ViewPager的使用
- poj 1164 The Castle 位运算+并查集/搜索
- UVA387给几个碎片去拼成一个4*4的正方形
- nyoj96
- 在用FragmentController类管理Fragment时报的RutimeError
- Hibernate之继承映射