日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

C++简单文件操作

發(fā)布時(shí)間:2025/7/25 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C++简单文件操作 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
View Code #include?"stdafx.h"
#include<fstream>
#include?<iostream>
using?namespace?std;

int?_tmain(int?argc,?_TCHAR*?argv[])
{
????//文件寫(xiě)入操作
????/*int?s=0;????
????ofstream?fileout("a.doc");
????if(!fileout){
????????cout<<"文件打開(kāi)失敗"<<endl;
????}
????while(s<=10){
????????fileout<<s<<"+1="<<++s<<endl;
????}
????cout<<"寫(xiě)入成功"<<endl;
????fileout.close();
*/

????char?ch;
????ofstream?f2;
????f2.open("D:\\data2.txt");//默認(rèn)ios::out?不存在則創(chuàng)建
????if(!f2){
????????cerr<<"錯(cuò)誤"<<endl;
????????exit(1);
????}
????while((ch=cin.get())!=EOF)//Ctrl+Z?組合?代表文件結(jié)束符EOF
????{
????????f2<<ch;????????
????????//f2.put(ch);
????}
????f2.close();
????int?a;
????cin>>a;
????return?0;
}

轉(zhuǎn)載于:https://www.cnblogs.com/clc2008/archive/2012/03/19/2405386.html

總結(jié)

以上是生活随笔為你收集整理的C++简单文件操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。