纯c++读写文件方式
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif#include"stdafx.h"http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif#include<iostream>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif#include<vector>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif#include<algorithm>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif#include<fstream>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif#include<string>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingnamespacestd;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifint_tmain(intargc,_TCHAR*argv[])
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gififstreaminfile("ReadMe.txt");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifofstreamsortfile("sort.txt");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifstringtempstring;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifvector<string>v;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifif(!infile||!sortfile)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcerr<<"errorwhileopenfile";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifreturn-1;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifwhile(infile>>tempstring)v.push_back(tempstring);//reading.......
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifsort(v.begin(),v.end());
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giffor(inti=0;i<v.size();i++)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcout<<v<<"";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifsortfile<<v<<"";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifreturn0;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
页:
[1]