
c++文件操作
行码阁119
这个作者很懒,什么都没留下…
展开
-
C++文件操作-二进制读文件
# include<iostream># include<string># include<fstream>using namespace std;class Person{public: char m_Name[64]; int m_Age;};void test01(){ //1、包含头文件 //2、创建流对象 ifstream ifs; //3、打开文件,判断是否判断成功 ifs.open("person.txt"...原创 2021-10-06 17:32:20 · 384 阅读 · 0 评论 -
C++文件操作-二进制文件
Write函数需要写入地址,所以需要传入&p,但是代码定义为类,需将其地址转换为字符型,强制类型转换# include<iostream># include<fstream>using namespace std;class Person{public: char m_Name[64];//姓名 int m_Age; //年龄};void test01(){ //包含头文件 //创建流对象 ofstream ofs; //...原创 2021-10-06 17:18:39 · 323 阅读 · 0 评论 -
C++文件操作-读文件
# include<iostream># include<fstream># include<string>using namespace std;//文本文件的读文件int test01(){ //1、包含头文件 //2、创建流对象 ifstream ifs; //3、打开文件判断是否打开成功 ifs.open("test.txt",ios::in); if (!ifs.is_open()) //文件打开失败:路径失败 { cou...原创 2021-10-06 16:51:08 · 214 阅读 · 0 评论 -
C++文件操作 写文件
# include<iostream># include<string># include<fstream>using namespace std;//文本文件的写文件void test01(){ //1、包含头文件fstream //创建流对象 ofstream ofs; //out file //3、指定打开方式 ofs.open("test.txt", ios::out); //4写内容 ofs...原创 2021-10-06 16:16:06 · 113 阅读 · 0 评论