青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

The Way of C++

  C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
  55 Posts :: 0 Stories :: 19 Comments :: 0 Trackbacks

公告

The first time i use this blog, i will write something that i learn which i think is worth write down.

常用鏈接

留言簿(3)

我參與的團(tuán)隊(duì)

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

    Forgive my ugly English description ,and i may it will help you. -_-
    (Reference by : http://www.cplusplus.com/reference/iostream/istream/getline.html)
    the function prototype is as follows:
    istream& getline (char* s, streamsize n );
    istream& getline (char* s, streamsize n, char delim );
    
    the function extracts charatcters from the input sequence and stores them as c-tring into the array begin at s. Characters are extracted until either n-1 characters have been extracted or the delimiting character is found.( the char delim can be specified by yourself, or be '\n' by default). Remember this, when the delimiter is found ,it will be extracted and discarded, i.e, it is extracted from the input stream and not stored to the s , and the next input operation will begin after this extracted delimiter. ). After the data extracted ,the ending null charactor ('\0') will be appended to s automatically.
    The following is same examples.
    
 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     char fruit[100];
 6     cin.getline(fruit,100,'*');
 7     cout<<fruit<<endl;
 8     
 9     system("pause");
10 }
11 
    
    now ,when you input "banana apple pear\n"( here \n means the enter), then the console will show "banana apple pear"
   
   also ,you can specify the delimiter by yourself  as this.
  
 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     char fruit[100];
 6     cin.getline(fruit,100,'*');
 7     cout<<fruit<<endl;
 8     
 9     system("pause");
10 }
11 
    now,when you input "banana apple pear * orange\n",then the console will show " banana apple pera" , here the orange is not readed because is is after the delimiter '*'.
    
    So simple about use this function ,right ? now see this example .
    
 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     char fruit[100];
 6     while(cin.getline(fruit,100,'*'))
 7     {
 8         cout<<fruit<<endl;
 9     }
10     
11     system("pause");
12 }
13 
  Here we want to input number of lines ,each of line is delimited by a '*'.
  In the first time : we input " banana apple *\n" then the console show "banana apple" ,this is right.
  But the problem comes, in the second input " pear orange *\n", now the console show "\n(\n means a blank line) pear orange". Here a blank line will be output, betray to our will that showing "pear orange";
   The problem is that a '\n' is stored in the fruit in the second time as the first element, i.e, the fruit is "\npear orange\0" in the second input. In the first getline ,it extracted the input stream until the first '*' was found, then it discarded the '*', but the following character is '\n' which you input in the first time, this '\n' is still in the input stream. And the second getline read the stream form this '\n'. As we know ,the delimiter is specified as '*' ,so the '\n' is not a delimiter here ,and it will be stored into the second fruit. 
   How to resovle this problem ? In order to avoid the situation above ,we can use the get to extract the '\n' character. And now it work normally.
  
 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     char fruit[100];
 6     while(cin.getline(fruit,100,'*'))
 7     {
 8         cin.get();
 9         cout<<fruit<<endl;
10     }
11     
12     system("pause");
13 }
14 
   
   One thing you have to remember is that this is a function of the cin.
   there is also a global function getline() in the heder <string>. But you must use string object as parameter instead of c-string.  See the following example. 
   (Reference to :http://www.cplusplus.com/reference/string/getline.html)
  
 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 int main()
 5 {
 6     string s;
 7     getline(cin,s,'*');
 8     cout<<s<<endl;
 9     system("pause");
10 }
11 
    As you can see, the first parameter is istream object on which the extraction operation is performed. The second parameter str is the string object where the extracted content is stored. The Third parameter delim is the delimiting character. The operation of extracting succesive characters is stopped when this delimeter is read. And it will be etracted and discarded. 
   
   
  
  


   
    
    
  
posted on 2007-12-26 17:55 koson 閱讀(1075) 評論(3)  編輯 收藏 引用 所屬分類: C/C++

Feedback

# re: About the use of getline() 2007-12-27 12:21 夢在天涯
good , where are you in ?
your english is good!
  回復(fù)  更多評論
  

# re: About the use of getline()[未登錄] 2007-12-27 12:28 Koson
thx, i'm in guangzhou. Actually, i write this using the reference of the website. But i think this may be a way to improve the written english , despite the content is as simple as that. -_-  回復(fù)  更多評論
  

# re: About the use of getline()[未登錄] 2007-12-27 14:00 jarod
..... where are u in ?..................

should be

where are u..........  回復(fù)  更多評論
  

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美人在线观看| 欧美黑人多人双交| 国产精品亚洲网站| 久久国产精品久久久久久电车| 一本色道久久88综合日韩精品| 欧美精品一区三区在线观看| 正在播放欧美一区| 亚洲在线一区二区| 国内久久精品视频| 亚洲黄色在线观看| 国产精品第一区| 久久电影一区| 两个人的视频www国产精品| 亚洲精品中文字幕有码专区| 在线视频亚洲| 影音欧美亚洲| 一本久道久久综合中文字幕| 国产欧美一区二区三区久久人妖| 久久资源在线| 国产精品久久久久久av福利软件 | 欧美成人精品不卡视频在线观看 | 一区二区电影免费观看| 国产日韩欧美日韩| 最新成人av网站| 国产一区999| 亚洲精品一区二区三| 国产一区白浆| 中文无字幕一区二区三区| 红桃视频国产精品| 在线亚洲电影| 亚洲精品久久久久| 久久不射电影网| 午夜亚洲影视| 欧美另类在线播放| 噜噜噜躁狠狠躁狠狠精品视频| 欧美日韩视频在线| 欧美激情一区二区三区成人| 国产精品久久久久7777婷婷| 亚洲欧洲在线视频| 在线成人免费观看| 香蕉精品999视频一区二区| 一级成人国产| 欧美国产在线视频| 久久综合狠狠综合久久激情| 国产精品www| 99精品黄色片免费大全| 亚洲国产精品久久久久秋霞不卡 | 欧美a级一区| 久热re这里精品视频在线6| 国产精品www色诱视频| 亚洲欧洲三级| 亚洲国产精品久久久| 久久九九国产| 老**午夜毛片一区二区三区| 国产麻豆日韩| 午夜精品久久久久久久99水蜜桃| 亚洲午夜电影| 欧美日韩国产不卡| 99热精品在线| 亚洲一区区二区| 欧美日韩国产在线播放网站| 亚洲日韩视频| 一区二区三区精品久久久| 欧美国产激情二区三区| 亚洲第一区在线| 夜夜嗨av一区二区三区四区| 欧美激情国产高清| 亚洲人体一区| 亚洲先锋成人| 国产精品一区二区视频| 亚洲欧美日韩高清| 久久久久国产精品人| 国内精品久久久| 久久男人资源视频| 亚洲高清视频一区二区| 亚洲精品一区中文| 欧美日韩一区二区三区在线视频| 亚洲精品日韩一| 亚洲欧美日韩另类| 国产主播精品在线| 免费一级欧美片在线播放| 亚洲狠狠婷婷| 亚洲欧美一区二区三区极速播放| 国产情人综合久久777777| 久久aⅴ国产紧身牛仔裤| 欧美大成色www永久网站婷| 日韩午夜在线观看视频| 国产精品大全| 久久这里有精品15一区二区三区 | 久久av资源网站| 在线欧美小视频| 欧美日韩精品二区| 小处雏高清一区二区三区| 欧美11—12娇小xxxx| 一区二区欧美亚洲| 国产亚洲精品福利| 欧美精品三级| 久久激情视频久久| 日韩午夜精品| 麻豆精品视频在线观看视频| 一区二区三区视频在线观看| 国产午夜精品一区理论片飘花| 久久婷婷国产麻豆91天堂| 亚洲美女在线观看| 久久综合九九| 欧美一区二区三区四区在线观看地址| 亚洲电影自拍| 国产日韩欧美综合| 欧美无乱码久久久免费午夜一区| 久久成人综合视频| 亚洲一级黄色| 欧美午夜视频一区二区| 久久精品视频在线| 亚洲制服丝袜在线| 91久久国产精品91久久性色| 久久国产精品高清| 中文一区在线| 亚洲精品欧美日韩| 国产午夜亚洲精品理论片色戒| 欧美日韩中文字幕日韩欧美| 久久婷婷一区| 久久黄色影院| 新片速递亚洲合集欧美合集| 9l视频自拍蝌蚪9l视频成人| 欧美成人影音| 久久亚洲精品伦理| 久久精品一区二区三区不卡| 亚洲一区二区三区激情| 亚洲日本欧美日韩高观看| 一区二区三区在线不卡| 国产亚洲欧美色| 国产欧美婷婷中文| 国产精品免费小视频| 欧美色视频一区| 欧美日韩在线视频首页| 欧美国产视频一区二区| 免费日韩av| 欧美大尺度在线观看| 欧美成人69av| 欧美成人中文字幕| 欧美电影免费网站| 欧美福利视频| 欧美精品18+| 久久精品亚洲国产奇米99| 欧美在线网站| 久久精品免费| 久久夜色精品国产欧美乱| 久久婷婷蜜乳一本欲蜜臀| 噜噜爱69成人精品| 亚洲国产成人不卡| 亚洲日韩欧美一区二区在线| 日韩视频在线一区| 亚洲影院色在线观看免费| 小黄鸭视频精品导航| 久久久久久精| 免费观看在线综合| 欧美日韩精品| 国产一区视频网站| 亚洲国产日韩一区| 在线视频精品一区| 性欧美18~19sex高清播放| 久久精品中文| 欧美高清在线观看| 99亚洲视频| 欧美一区二区日韩一区二区| 欧美一区三区二区在线观看| 久久五月天婷婷| 欧美日韩久久不卡| 国产精品一香蕉国产线看观看 | 怡红院精品视频| 亚洲美女在线观看| 午夜精品久久久久久久蜜桃app | 亚洲国产日韩在线| 亚洲视频视频在线| 久久激情一区| 亚洲人体大胆视频| 亚洲一区二区精品| 蜜桃伊人久久| 国产麻豆午夜三级精品| 在线免费观看日本欧美| 亚洲在线一区二区三区| 久久久久91| 国产精品99久久久久久人| 久久成人资源| 国产精品日日摸夜夜添夜夜av| 在线观看一区视频| 欧美淫片网站| 日韩一区二区高清| 久久综合九色九九| 国产欧美日韩视频在线观看| 亚洲精品久久久久久一区二区 | 欧美一区二区三区四区在线观看地址 | 欧美精品一区二区三区视频| 好看的av在线不卡观看| 亚洲综合社区| 亚洲破处大片| 玖玖玖免费嫩草在线影院一区| 国产精品日韩电影| 这里只有精品视频在线| 欧美激情国产日韩|