C++可以通过文件流fstream来实现对Txt文档的读写操作 一、写入文件 #include using namespace std; void main(){ofstream in; in.open("com.txt",ios::trunc); //ios::trunc表示在打开文件前将文件清空,由于是写入,文件不存在则创建