<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      c++ ignore

      std::cin.ignore() can be called three different ways:

      1.No arguments: A single character is taken from the input buffer and discarded:
      std::cin.ignore(); //discard 1 character
      2.One argument: The number of characters specified are taken from the input buffer and discarded:
      std::cin.ignore(33); //discard 33 characters
      3.Two arguments: discard the number of characters specified, or discard characters up to and including the specified delimiter (whichever comes first):
      std::cin.ignore(26, '\n'); //ignore 26 characters or to a newline, whichever comes first




      舉例:

      cin.ignore(1000, '\n')的含義是把緩沖區內從當前字符開始知道'\n'之前字符(如果有1000個的話)忽略掉,實際上你這里假設一行不會超過1000個字符,所以含義是忽略一行
      ②新建個文件abc.txt,然后把下面這幾句話拷貝到里面:
      the, quick, brown, fox, jumps, over, the, lazy, dog

      運行程序,輸入"abc.txt"。注意,abc.txt這個文件,一定要跟你這個.cpp源文件在同一個目錄里。
      infile.ignore(200,','); //跳過200個字符,直到遇到','為止,所以跳過了"the,"
      infile>>a; //讀入一個字符串,即"quick,",因為默認情況下空格是讀取分隔符
      infile.ignore(200,','); //跳過200個字符,直到遇到','為止,所以跳過了"brown,"
      infile>>b; //讀入一個字符串,即"fox,",注意空格是分隔符
      infile.ignore(200,','); //跳過"jumps,"
      infile>>c; //讀取"over,"
      最后的輸出結果就是
      quick,
      fox,
      over,



      #include "stdafx.h"
      #include
      #include
      #include
      #include

      using namespace std;
      class Person{
          public:
              int id;
              string name;
              string age;
      };
      istream& operator>>( istream& is, Person& per ){
          is>>per.id && is.ignore() && getline(is,per.name,',') && is>>per.age;//ignore忽略掉一個字符,讀完id后跳過1個字符
          return is;
      }
      ostream& operator<<(ostream& os, const Person& per){
          return os << per.id << ',' << per.name << ',' << per.age;
      }

      int _tmain(int argc, _TCHAR* argv[])
      {
          ifstream inFile("1.txt");
          if (!inFile){
              return -1;
          }

          vector personVec;

          for(Person per; inFile>>per;){
              personVec.push_back(per);
          }

          for(vector::iterator itor=personVec.begin(); itor!=personVec.end(); ++itor){
              cout << *itor << '\n';
          }
          cout << endl;


          return 0;
      }

      文本為:
      1001,xiaoming,30
      1002,Laoming,40
      1003,Dming,50

      若文本為
      1001-xiaoming-30  則需要getline(is,per.name,',')改為getline(is,per.name,'-')

      若文本為
      xiaoming-30,2 則需要getline(is,per.name,'-') && is>>per.age && is.ignore() && is>>per.id;

      若文本為
      IF1304,2014-12-23 09:15.500
      IF1305,2014-12-24 09:16.600
      IF1306,2014-12-25 09:17.700

      istream& operator>>( istream& is, Person& per ){
          //is>>per.id && is.ignore() && getline(is,per.name,'-') && is>>per.age;//ignore忽略掉一個字符,讀完id后跳過1個字符
          //getline(is,per.name,'-') && is>>per.age && is.ignore() && is>>per.id;
          getline(is,per.inst,',') && is >> per.year && is.ignore() && is >> per.month && is.ignore() && is >> per.day && is.ignore()
              && is >> per.hour && is.ignore() && is >> per.min && is.ignore() && is >> per.tick;

          return is;
      }
      ostream& operator<<(ostream& os, const Person& per){
          return os << per.inst << ',' << per.year << '-' << per.month << "-" << per.day << " " << per.hour << ":" << per.min << "." <<per.tick;
      }
      其中類為
      class Person{
          public:
              string inst;
              int year;
              int month;
              int day;
              int hour;
              int min;
              int sec;
              int tick;
      };

      若文本為
      IF1305 455 33
      IF1304 4535 344
      IF1345 4553 35

      is >> per.inst >> per.year >> per.month;若文本中均為空格 則直接讀就行,因為----cin自動過濾tab、空格、回車?。?!

      posted @ 2022-02-21 17:05  myd620  閱讀(111)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产欧美日韩亚洲一区二区三区| 国产成人亚洲精品成人区| 国产欧美VA天堂在线观看视频| 好吊视频一区二区三区| 欧美成人精品三级网站| 亚洲欧美日韩综合一区在线| 无码人妻一区二区三区四区AV | 精品一卡2卡三卡4卡乱码精品视频| 蜜臀av在线观看| 亚洲欧美综合一区二区三区| 亚洲av色香蕉一区二区三| 嫩草研究院久久久精品| 国产精品大全中文字幕| 国产一区二区亚洲一区二区三区| 色AV专区无码影音先锋| 东台市| 高清在线一区二区三区视频| 亚洲人妻中文字幕一区| 国产av剧情md精品麻豆| 国产一区二区三区四区五区加勒比| 日韩精品一卡二卡三卡在线| 国产福利微视频一区二区| 无码伊人久久大杳蕉中文无码| 国产精品伊人久久综合网| 俺来也俺去啦最新在线| 国产精品免费视频不卡| 国产精品小视频一区二页| 午夜福利在线观看成人| 国产精品99中文字幕| 丰满巨乳淫巨大爆乳| 久久精品不卡一区二区| 亚洲人成在线播放网站| 亚洲欧洲日产国码无码网站| 色狠狠色婷婷丁香五月| 中国凸偷窥xxxx自由视频| 久久久久香蕉国产线看观看伊| 久久亚洲国产精品久久| 国产精品无码v在线观看| 最新国产精品好看的精品| 少妇熟女久久综合网色欲| 婷婷国产成人精品视频|