Open() 用于创建文件和打开现有文件.有人能分辨出其中的区别
Open() is used for creating a file and opening a existing file.Could someone tell the difference?
我已经用open((创建了一个文件名c.txt,如果我想在文件中进行更改,那么我将使用open((打开,那么有什么区别?有人可以帮我吗?
#include "stdafx.h"
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream myfile;
myfile.open("c.txt");
myfile << "gm all";
myfile.close();
}
这很简单!
流:输出流。ifstream:输入流。
使用 ofstream 创建文件,并使用 ifstream 打开它。
相关文章:
- 多个文件的内存分配错误"在抛出 'std :: bad_alloc' what (): std :: bad_alloc 的实例后终止调用" [C++]
- 如何在文件和行号中抛出错误
- cmath抛出错误C2062、C2059、C2143和C2447.cmath包含在矢量文件中
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 遍历顺序由 std::文件系统directory_iterator给出
- 捕获标准输出以压缩并使用 CTRL-C 中断会给出损坏的 zip 文件
- 如何使字符串出现在编译的二进制可执行文件的开头?
- 使用 find 解析文件会给出不同文件的奇怪结果
- 从文件中读取数组没有给出正确的值?
- 尝试读取.txt文件并根据用户输入的字母拉出特定行
- 如果在命令行c++中给出了一个文件,那么如何读取该文件
- 进口。TLB文件给出"cannot open source file x.tlh"
- 挂钩创建文件抛出异常:读取访问冲突
- Open() 用于创建文件和打开现有文件.有人能分辨出其中的区别
- -O2 优化不会在读取大文件时出圈
- 从C 中的.txt文件打印出所选的数据
- 我可以分辨出在C++中使用"new type[n]"创建的数组的大小吗?
- 我能从分段错误中分辨出一些东西吗
- 预编译头文件给出了216个错误
- 由中间对象文件抛出的对c++函数的未定义引用