C++文件打开
来源:互联网 发布:网络推广岗位说明书 编辑:程序博客网 时间:2024/05/01 03:23
打开文件,如果文件不存在不新建
#include <fstream.h>
#include <stdlib.h> //exit()
int main()
{
ifstream infile;
infile.open("myfile.dat",ios::nocreate);
if(infile.fail())
{
cout << "the file are notsuccessfully opened"<<endll;
exit(1);
}
cout<<"the file has beensuccessfully opened for reading";
return 1;
}
任何被打开的文件在程序结束后都会自动被操作系统关闭。
关闭文件可以使用infile.close();
可以使用符号 <<
ofstream outfile;
outfile.open(filename);
outfile << "hello world";
- [C#]拖动打开文件
- C二进制打开文件
- c中打开文件
- c++/c fopen_s打开文件
- c#-文件打开与保存,打开文件夹
- C语言文件打开方式
- C语言文件打开模式
- C语言 文件打开方式
- c语言打开文件方式
- C语言文件打开方式
- 【C#】 打开文件浏览窗口
- 关于C打开文件失败
- 【C语言】文件打开方式
- 【C语言】C\C++ 文件打开方式
- C实例---文件操作(打开文件)
- C语言文件打开和二进制打开方式的区别
- C打开文件的追加参数
- C打开文件的追加参数
- 新浪sina微博weibo系统开发工程师j…
- 精选微软等公司数据结构+算…
- awk使用
- g++和gcc的关系
- 使用ifstream和getline读取文件内…
- C++文件打开
- 百度面试题
- openssl/md5.h 出错解决方案
- linux编程
- Bloom-Filter算法简介
- Spectral Bloom Filter算法
- 递归特例-斐波那契数列
- C#连接Oracle数据库
- awk内置字符串函数