11-3

发布时间 2023-03-27 22:28:50作者: nlkdfgnvfdkl

使用I/O流以文本方式建立一个文件test1.txt,写入字符“已成功写入文件!”,用其它字处理程序(例如windows的记事本程序Notepad)打开,看看是否正确写入。

 1 #include <iostream>
 2 #include <string>
 3 #include<string.h>
 4 #include <fstream>
 5 using namespace std;
 6 
 7 
 8 int main(){
 9     ofstream file("text1.txt");
10     file<<"已成功写入文件!";
11     file.close();
12     return 0;
13 }