Open() 用于创建文件和打开现有文件.有人能分辨出其中的区别

Open() is used for creating a file and opening a existing file.Could someone tell the difference?

本文关键字:文件 分辨出 区别 用于 创建 Open      更新时间:2023-10-16

我已经用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 打开它。