如何创建一个有效的海淀网站建设电话网络信息发布平台?

摘要:海淀网站建设电话,网络信息发布平台,wordpress网站文章加密,网站页面建设方案书模板之前写过两篇跟文件操作相关的博客,有兴趣也可以看一下: C语言读写文件 Qt关于文件路径的
海淀网站建设电话,网络信息发布平台,wordpress网站文章加密,网站页面建设方案书模板之前写过两篇跟文件操作相关的博客#xff0c;有兴趣也可以看一下#xff1a; C语言读写文件 Qt关于文件路径的处理 先讲一些关于基础文本文件和二进制文件的读写操作#xff0c;后续将会整理C/Qt关于ini、xml、json、xlsx相关文件的读写操作。 C 相比于C语言使用FILE文…之前写过两篇跟文件操作相关的博客有兴趣也可以看一下 C语言读写文件 Qt关于文件路径的处理 先讲一些关于基础文本文件和二进制文件的读写操作后续将会整理C/Qt关于ini、xml、json、xlsx相关文件的读写操作。 C 相比于C语言使用FILE文件指针来实现文件操作C 采用的是标准库中的fstream类来实现文件的打开、关闭、读取和写入。 引入头文件 #include fstream 打开文件 explicit ifstream(const char* fileName, ios_base::openmode mode ios_base::in);explicit ifstream(const string fileName, ios_base::openmode mode ios_base::in);第一个参数表示文件名第二个表示打开方式关于打开方式有以下几种,以下是官方给出的定义说明 // 27.4.2.1.4 Type ios_base::openmode/*** brief This is a bitmask type.** c a _Ios_Openmode is implementation-defined, but it is valid to* perform bitwise operations on these values and expect the Right* Thing to happen. Defined objects of type openmode are:* - app* - ate* - binary* - in* - out* - trunc*/typedef _Ios_Openmode openmode;/// Seek to end before each write.static const openmode app _S_app;/// Open and seek to end immediately after opening.static const openmode ate _S_ate;/// Perform input and output in binary mode (as opposed to text mode)./// This is probably not what you think it is; see/// https://gcc.gnu.org/onlinedocs/libstdc/manual/fstreams.html#std.io.filestreams.binarystatic const openmode binary _S_bin;/// Open for input. Default for c ifstream and fstream.static const openmode in _S_in;/// Open for output. Default for c ofstream and fstream.static const openmode out _S_out;/// Open for input. Default for c ofstream.static const openmode trunc _S_trunc;ios::in以读取的方式打开文件ios::out以写入的方式打开文件如果文件不存在则会创建文件ios::ate打开文件时定位到文件尾部ios::app以追加的形式打开文件写入的内容将会添加到文件末尾ios::trunc打开文件时将清空文件原有的内容ios::binary以二进制的方式打开文件 这些方式可以采用“|”组合使用例如 fstream file;file.open(1.txt, ios::out | ios::app); 以写入的方式打开文件1.txt,写入的内容将会追加到文件末尾。
阅读全文