|
|
#3
yuyunliuhen2007-06-07 23:25
read file ? for example: #include<iostream> #include<fstream> #include<string> #include<cstdlib> using namespace std; int main() { fstream fin; fin.open("d:\\filename.txt"); //the file path if(fin.is_open()==false) { cerr<<"Can not open file,bye!\n"; exit(EXIT_FALLURE); } string item; int count=0; getline(fin,item,':'); while(fin){ count++; cout<<count<<":"<<item<<endl; getline(fin,item,':'); } cout<<"done!"<<endl; fin.close();
return 0; }
|