#include <iostream>
#include <fstream>
int main(int argc, char** argv) {
//app是追加的意思,append
//盘符后面一定是双斜杠 \\
//没有这个文件,会自动创建
std::ofstream outfile("e:\\123.txt",std::ios::app);
if(outfile.is_open()){
outfile<<"ccccc";<pre name="code" class="cpp"><span style="white-space:pre"> </span>std::cout<<"写入成功!"<<std::endl;
//outfile<<"ccccc"<<"\n";会换行 }else{std::cout<<"没有写入成功!"<<std::endl; } return 0;}
调试截图