2、stream.h>set,withfileinputandoutputoperationsofthebuffer.Infact,hasbeenincluded,soyoudonothavetoincludeallthetwofiles,ifyouwanttoexplicitlyincludethem,it'suptoyou.Westartwiththedesignofthefilemanipulationclass,andI'llexplainhowtodotheASCIII/Ooperation.Ify
3、ouguessed"fstream,"Congratulations,yougotit!Butthemethodintroducedinthisarticle,weuse"ifstream"and"OFSTREAM"respectivelyasinputandoutput.Ifyou'veusedthestandardconsoleflow"CIN"and"cout",it'seasyforyounow.Let'sbeginwiththeoutputsection,andfirstdeclareaclassobject.OFSTREAMfout;th
4、at'sallright,butifyouwanttoopenafile,youmustcallofstream::open()likethis.Fout.open("output.txt");youcanalsousethefilenameasaconstructortoopenafileOFSTREAMfout("output.txt");thisisthemethodweuse,becauseitcreatesandopensafilelooksmoresimple.Bytheway,ifyouwanttoopenthefiledoesnote
5、xist,itwillbecreatedforyou,soyoudon'tneedtoworryaboutcreatingthefile.Theoutputtothefile,looklike"cout"operation.Forpeoplewhodon'tknowtheconsoleoutput"cout",here'sanexample.Intnum=150;Charname[]="JohnDoe"";Fout"Hereisanumber:","num""/n"";"Nowherefout"isastring:""name""/n";nowtos
6、avethefile,youmustclosethefile,orthefilewritebackbuffer.Closingthefilewillnotbeoperated,soonlywhenyoudon'toperatethisfiletocallit,itwillautomaticallysavethefile.Thewritebackbuffersavesthefilewhenthefileisopen,souseitaslongasitisnecessary.Thewritebacklookslikeanotheroutput,andth
7、encallsthemethodtoclose.Likethis:Fout"flush;fout.close()";nowyouopenthefilewithatexteditor,anditlookslikethis:Hereisanumber:Nowhereisastring:150JohnDoeisverysimple!Nowcontinuetofileinput,needalittleskill,somakesureyoualreadyknowtheflowofoperations,""and""familiarwith,becauseyou
8、thenhavetousethem.Continue...Two,ASCIIinputTheinputisv