C++中简单的对文件的读取操作...

      计算机与编程 2007-7-3 11:39:00

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

main()
{
 ifstream infile ("wangs_input.txt");
 string wangs_name;
 string wangs_id;
 int wangs_num;

 loop: while (infile >> wangs_name)
 {
  infile >> wangs_id >> wangs_num;
  cout << wangs_name <<" "<< wangs_id <<" "<< wangs_num <<endl;

  if (wangs_name=="value")
  {
   cout<<"welcome back...\n";
   goto loop; // that means ifstream can remember the stats...
  }
 }

 return 0;
}

标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}