亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch16.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
extraction operation can be the input to the next extraction.</P>
<PRE><FONT COLOR="#0066FF">int VarOne, varTwo, varThree;
cout &lt;&lt; &quot;Enter three numbers: &quot;
cin &gt;&gt; VarOne &gt;&gt; varTwo &gt;&gt; varThree;
</FONT></PRE>
<P>When you write <TT>cin &gt;&gt; VarOne &gt;&gt; varTwo &gt;&gt; varThree;</TT>,
the first extraction is evaluated <TT>(cin &gt;&gt; VarOne)</TT>. The return value
from this is another <TT>istream</TT> object, and that object's extraction operator
gets the variable <TT>varTwo</TT>. It is as if you had written this:</P>
<PRE><FONT COLOR="#0066FF">((cin &gt;&gt; varOne) &gt;&gt; varTwo) &gt;&gt; varThree;
</FONT></PRE>
<P>You'll see this technique repeated later when <TT>cout</TT> is discussed.
<H3 ALIGN="CENTER"><A NAME="Heading24"></A><FONT COLOR="#000077">Other Member Functions
of cin</FONT></H3>
<P>In addition to overloading <TT>operator&gt;&gt;</TT>, <TT>cin</TT> has a number
of other member functions. These are used when finer control over the input is required.
<H4 ALIGN="CENTER"><A NAME="Heading25"></A><FONT COLOR="#000077">Single Character
Input</FONT></H4>
<P><TT>operator&gt;&gt;</TT> taking a character reference can be used to get a single
character from the standard input. The member function <TT>get()</TT> can also be
used to obtain a single character, and can do so in two ways. <TT>get()</TT> can
be used with no parameters, in which case the return value is used, or it can be
used with a reference to a character. Using get() with No Parameters The first form
of <TT>get()</TT> is without parameters. This returns the value of the character
found, and will return <TT>EOF</TT> (end of file) if the end of the file is reached.
<TT>get()</TT> with no parameters is not often used. It is not possible to concatenate
this use of <TT>get()</TT> for multiple input, because the return value is not an
<TT>iostream</TT> object. Thus, the following won't work:</P>
<PRE><FONT COLOR="#0066FF">cin.get() &gt;&gt;myVarOne &gt;&gt; myVarTwo; //   illegal
</FONT></PRE>
<P>The return value of (<TT>cin.get() &gt;&gt; myVarOne</TT>) is an integer, not
an <TT>iostream</TT> object.</P>
<P>A common use of <TT>get()</TT> with no parameters is illustrated in Listing 16.4.</P>
<P><A NAME="Heading26"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 16.4. Using
get() with no parameters.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:     // Listing 16.4 - Using get() with no parameters
2:     #include &lt;iostream.h&gt;
3:
4:     int main()
5:     {
6:        char ch;
7:        while ( (ch = cin.get()) != EOF)
8:        {
9:           cout &lt;&lt; &quot;ch: &quot; &lt;&lt; ch &lt;&lt; endl;
10:       }
11:       cout &lt;&lt; &quot;\nDone!\n&quot;;
12:     return 0;
<TT>13: }</TT></FONT></PRE>


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>To exit this program, you must send
	end of file from the keyboard. On DOS computers use Ctrl+Z; on UNIX units use Ctrl+D.
	
<HR>


</BLOCKQUOTE>

<PRE><FONT COLOR="#0066FF">Output: Hello
ch: H
ch: e
ch: l
ch: l
ch: o
ch:

World
ch: W
ch: o
ch: r
ch: l
ch: d
ch:

 (ctrl-z)
Done!
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis</B></FONT><FONT COLOR="#000000"><B>:</B></FONT><FONT
COLOR="#000077"><B> </B></FONT>On line 6, a local character variable is declared.
The <TT>while</TT> loop assigns the input received from <TT>cin.get()</TT> to <TT>ch</TT>,
and if it is not <TT>EOF</TT> the string is printed out. This output is buffered
until an end of line is read, however. Once <TT>EOF</TT> is encountered (by pressing
Ctrl+Z on a DOS machine, or Ctrl+D on a UNIX machine), the loop exits.</P>
<P>Note that not every implementation of <TT>istream</TT> supports this version of
<TT>get()</TT>. Using get() with a Character Reference Parameter When a character
is passed as input to <TT>get()</TT>, that character is filled with the next character
in the input stream. The return value is an <TT>iostream</TT> object, and so this
form of <TT>get()</TT> can be concatenated, as illustrated in Listing 16.5.</P>
<P><A NAME="Heading27"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 16.5 Using get()
with parameters.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:     // Listing 16.5 - Using get() with parameters
2:     #include &lt;iostream.h&gt;
3:
4:     int main()
5:     {
6:        char a, b, c;
7:
8:        cout &lt;&lt; &quot;Enter three letters: &quot;;
9:
10:       cin.get(a).get(b).get(c);
11:
12:       cout &lt;&lt; &quot;a: &quot; &lt;&lt; a &lt;&lt; &quot;\nb: &quot; &lt;&lt; b &lt;&lt; &quot;\nc: &quot; &lt;&lt; c &lt;&lt; endl;
13:     return 0;
<TT>14: }</TT></FONT>
<FONT COLOR="#0066FF">
Output: Enter three letters: one
a: o
b: n
c: e
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis</B></FONT><FONT COLOR="#000000"><B>:</B></FONT><B>
</B>On line 6, three character variables are created. On line 10, <TT>cin.get()</TT>
is called three times, concatenated. First <TT>cin.get(a)</TT> is called. This puts
the first letter into <TT>a</TT> and returns <TT>cin</TT> so that when it is done,
<TT>cin.get(b)</TT> is called, putting the next letter into <TT>b</TT>. The end result
of this is that <TT>cin.get(c)</TT> is called and the third letter is put in <TT>c</TT>.</P>
<P>Because <TT>cin.get(a)</TT> evaluates to <TT>cin</TT>, you could have written
this:</P>
<PRE><FONT COLOR="#0066FF">cin.get(a) &gt;&gt; b;</FONT></PRE>
<P>In this form, <TT>cin.get(a)</TT> evaluates to <TT>cin</TT>, so the second phrase
is <TT>cin &gt;&gt; b;</TT>.


<BLOCKQUOTE>
	<P>
<HR>
<B>DO </B>use the extraction operator (<TT>&gt;&gt;</TT>) when you need to skip over
	white space. <B>DO</B> use <TT>get()</TT> with a character parameter when you need
	to examine every character, including white space. <B>DON'T </B>use <TT>get()</TT>
	with no parameters at all; it is more or less obsolete. 
<HR>


</BLOCKQUOTE>

<H4 ALIGN="CENTER"><A NAME="Heading28"></A><FONT COLOR="#000077">Getting Strings
from Standard Input</FONT></H4>
<P>The extraction operator (<TT>&gt;&gt;</TT>) can be used to fill a character array,
as can the member functions <TT>get()</TT> and <TT>getline()</TT>.</P>
<P>The final form of <TT>get()</TT> takes three parameters. The first parameter is
a pointer to a character array, the second parameter is the maximum number of characters
to read plus one, and the third parameter is the termination character.</P>
<P>If you enter <TT>20</TT> as the second parameter, <TT>get()</TT> will read 19
characters and then will null-terminate the string, which it will store in the first
parameter. The third parameter, the termination character, defaults to newline (<TT>`\n'</TT>).
If a termination character is reached before the maximum number of characters is
read, a null is written and the termination character is left in the buffer.</P>
<P>Listing 16.6 illustrates the use of this form of <TT>get()</TT>.</P>
<P><A NAME="Heading29"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 16.6. Using
get() with a character array.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:     // Listing 16.6 - Using get() with a character array
2:     #include &lt;iostream.h&gt;
3:
4:     int main()
5:     {
6:        char stringOne[256];
7:        char stringTwo[256];
8:
9:        cout &lt;&lt; &quot;Enter string one: &quot;;
10:       cin.get(stringOne,256);
11:       cout &lt;&lt; &quot;stringOne: &quot; &lt;&lt; stringOne &lt;&lt; endl;
12:
13:       cout &lt;&lt; &quot;Enter string two: &quot;;
14:       cin &gt;&gt; stringTwo;
15:       cout &lt;&lt; &quot;StringTwo: &quot; &lt;&lt; stringTwo &lt;&lt; endl;
16:     return 0;
<TT>17: }</TT></FONT>
<FONT COLOR="#0066FF">
Output: Enter string one: Now is the time
stringOne: Now is the time
Enter string two: For all good
StringTwo: For
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis</B></FONT><FONT COLOR="#000000"><B>:</B></FONT><B>
</B>On lines 6 and 7, two character arrays are created. On line 9, the user is prompted
to enter a string, and <TT>cin.get()</TT> is called on line 10. The first parameter
is the buffer to fill, and the second is one more than the maximum number for <TT>get()</TT>
to accept (the extra position being given to the null character, (<TT>`\0'</TT>)).
The defaulted third parameter is a newline.</P>
<P>The user enters <TT>Now is the time</TT>. Because the user ends the phrase with
a newline, that phrase is put into <TT>stringOne</TT>, followed by a terminating
null.</P>
<P>The user is prompted for another string on line 13, and this time the extraction
operator is used. Because the extraction operator takes everything up to the first
white space, the string <TT>For</TT>, with a terminating null character, is stored
in the second string, which of course is not what was intended.</P>
<P>Another way to solve this problem is to use <TT>getline()</TT>, as illustrated
in Listing 16.7.</P>
<P><A NAME="Heading31"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 16.7. Using
getline().</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:     // Listing 16.7 - Using getline()
2:     #include &lt;iostream.h&gt;
3:
4:     int main()
5:     {
6:        char stringOne[256];
7:        char stringTwo[256];
8:        char stringThree[256];
9:
10:       cout &lt;&lt; &quot;Enter string one: &quot;;
11:       cin.getline(stringOne,256);
12:       cout &lt;&lt; &quot;stringOne: &quot; &lt;&lt; stringOne &lt;&lt; endl;
13:
14:       cout &lt;&lt; &quot;Enter string two: &quot;;
15:       cin &gt;&gt; stringTwo;
16:       cout &lt;&lt; &quot;stringTwo: &quot; &lt;&lt; stringTwo &lt;&lt; endl;
17:
18:       cout &lt;&lt; &quot;Enter string three: &quot;;
19:       cin.getline(stringThree,256);
20:       cout &lt;&lt; &quot;stringThree: &quot; &lt;&lt; stringThree &lt;&lt; endl;
21:     return 0;
<TT>22: }</TT></FONT>
<FONT COLOR="#0066FF">
Output: Enter string one: one two three
stringOne: one two three
Enter string two: four five six
stringTwo: four
Enter string three: stringThree: five six
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis</B></FONT><FONT COLOR="#000000"><B>:</B></FONT><B>
</B>This example warrants careful examination; there are some potential surprises.
On lines 6-8, three character arrays are declared.</P>
<P>On line 10, the user is prompted to enter a string, and that string is read by
<TT>getline()</TT>. Like <TT>get()</TT>, <TT>getline()</TT> takes a buffer and a
maximum number of characters. Unlike <TT>get()</TT>, however, the terminating newline
is read and thrown away. With <TT>get()</TT> the terminating newline is not thrown
away. It is left in the input buffer.</P>
<P>On line 14, the user is prompted again, and this time the extraction operator
is used. The user enters <TT>four five six</TT>, and the first word, <TT>four</TT>,
is put in <TT>stringTwo</TT>. The string <TT>Enter string three</TT> is then displayed,
and <TT>getline()</TT> is called again. Because <TT>five six</TT> is still in the
input buffer, it is immediately read up to the newline; <TT>getline()</TT> terminates
and the string in <TT>stringThree</TT> is printed on line 20.</P>
<P>The user has no chance to enter string three, because the second <TT>getline()</TT>
call is fulfilled by the string remaining in the input buffer after the call to the
extraction operator on line 15.</P>
<P>The extraction operator (<TT>&gt;&gt;</TT>) reads up to the first white space
and puts the word into the character array.</P>
<P>The member function <TT>get()</TT> is overloaded. In one version, it takes no
parameters and returns the value of the character it receives. In the second version,
it takes a single character reference and returns the <TT>istream</TT> object by
reference.</P>
<P>In the third and final version, <TT>get()</TT> takes a character array, a number
of characters to get, and a termination character (which defaults to newline). This
version of <TT>get()</TT> reads characters into the array until it gets to one fewer
than its maximum number of characters or it encounters the termination character,
whichever comes first. If <TT>get()</TT> encounters the termination character, it
leaves that character in the input buffer and stops reading characters.</P>
<P>The member function <TT>getline()</TT> also takes three parameters: the buffer
to fill, one more than the maximum number of characters to get, and the termination
character. <TT>getline()</TT>functions exactly like <TT>get()</TT> does with these
parameters, except <TT>getline()</TT> throws away the terminating character.
<H4 ALIGN="CENTER"><A NAME="Heading32"></A><FONT COLOR="#000077">Using cin.ignore()</FONT></H4>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区精品| 男人的天堂久久精品| 精品国产免费久久| 欧美猛男男办公室激情| 欧美日韩视频专区在线播放| 欧美视频在线一区二区三区 | 国产精品久久久久天堂| 久久精品无码一区二区三区| 日本一区二区免费在线| 国产精品美女久久久久久2018| 欧美激情一区二区三区全黄| 国产精品视频一二三区| 亚洲精品成人精品456| 亚洲精品乱码久久久久久黑人 | 精品国产一区久久| 欧美国产综合一区二区| 最新中文字幕一区二区三区| 亚洲人成小说网站色在线| 依依成人精品视频| 秋霞午夜av一区二区三区| 国产精品综合网| 91免费看`日韩一区二区| 欧美日韩精品一区二区在线播放| 91精品国产色综合久久ai换脸 | 亚洲国产成人porn| 美国毛片一区二区| 不卡一区中文字幕| 在线综合亚洲欧美在线视频| 国产免费成人在线视频| 亚洲图片有声小说| 国产精品88888| 欧美午夜片在线看| 久久久噜噜噜久久中文字幕色伊伊| 中文字幕在线播放不卡一区| 天天色综合天天| www.99精品| 日韩免费高清电影| 亚洲久本草在线中文字幕| 久久精品国产第一区二区三区| 成人免费不卡视频| 91麻豆精品国产91久久久久久 | av一区二区三区四区| 欧美一区二区三区四区五区| 亚洲欧洲av一区二区三区久久| 日本不卡视频一二三区| 色老汉一区二区三区| 国产校园另类小说区| 日韩黄色在线观看| 91免费国产在线| 国产亚洲精品7777| 日本中文字幕不卡| 欧美色男人天堂| 成人欧美一区二区三区黑人麻豆| 国产专区综合网| 欧美一区二区女人| 亚洲成av人**亚洲成av**| 97se亚洲国产综合自在线不卡| www日韩大片| 久久99精品久久久久久动态图| 欧美综合一区二区三区| 亚洲人亚洲人成电影网站色| 国产91丝袜在线播放0| 久久青草国产手机看片福利盒子| 爽爽淫人综合网网站| 91精品福利在线| 亚洲精品日韩综合观看成人91| 成人免费电影视频| 自拍偷拍亚洲欧美日韩| www.成人在线| 又紧又大又爽精品一区二区| 色综合久久综合中文综合网| 中文字幕在线一区| 99精品国产91久久久久久 | 亚洲成人av一区| 欧美亚洲国产一区二区三区| 一区二区三区四区精品在线视频 | 欧美一二三在线| 喷白浆一区二区| 欧美xxxx老人做受| 国模娜娜一区二区三区| 久久精品一区二区| va亚洲va日韩不卡在线观看| 亚洲欧美一区二区在线观看| 色香色香欲天天天影视综合网| 伊人色综合久久天天人手人婷| 欧洲一区二区av| 丝袜国产日韩另类美女| 精品播放一区二区| av在线不卡电影| 亚洲线精品一区二区三区| 欧美一区二区三区喷汁尤物| 韩国女主播一区| 亚洲色图欧美偷拍| 欧美视频精品在线| 韩国中文字幕2020精品| 中文字幕一区二区三| 欧美视频在线观看一区二区| 久久er精品视频| 亚洲欧洲精品一区二区三区| 欧美日韩亚洲不卡| 国产成人免费视频精品含羞草妖精 | 欧美欧美欧美欧美首页| 激情综合网av| 1024亚洲合集| 日韩亚洲欧美在线| www.亚洲精品| 久久精品国产一区二区| 1024成人网| 日韩一区二区三区电影在线观看 | 免费成人在线观看| 国产精品成人午夜| 日韩一级精品视频在线观看| av资源站一区| 精品制服美女丁香| 亚洲激情男女视频| 国产亚洲欧美中文| 欧美精品在线观看一区二区| 成人激情校园春色| 久久成人羞羞网站| 亚洲美女少妇撒尿| 国产日韩欧美精品一区| 日韩一区二区精品在线观看| 色综合久久精品| 国产精品夜夜嗨| 美女mm1313爽爽久久久蜜臀| 亚洲免费色视频| 中文字幕一区在线观看| 久久久久久久电影| 日韩欧美中文字幕制服| 欧美性受极品xxxx喷水| 成人性视频免费网站| 极品少妇xxxx精品少妇| 天天操天天干天天综合网| 亚洲麻豆国产自偷在线| 国产精品网友自拍| 国产视频视频一区| 精品国产1区2区3区| 91精品国产综合久久精品| 欧洲国内综合视频| 在线免费观看日本一区| 91首页免费视频| 成人精品视频一区二区三区尤物| 日本aⅴ精品一区二区三区| 性做久久久久久久久| 亚洲精品国产成人久久av盗摄| 国产精品毛片a∨一区二区三区| 精品成人一区二区三区| 久久综合色天天久久综合图片| 日韩精品一区二区三区中文精品| 欧美精品黑人性xxxx| 欧美区在线观看| 欧美男人的天堂一二区| 欧美一区二区视频在线观看2022 | 亚洲福利一区二区三区| 亚洲综合小说图片| 亚洲国产精品人人做人人爽| 亚洲一区免费观看| 性久久久久久久久| 午夜精品国产更新| 视频一区国产视频| 久久精品国产免费| 国产麻豆午夜三级精品| 东方欧美亚洲色图在线| 99久久精品国产精品久久| 色94色欧美sute亚洲线路一ni| 欧美在线免费视屏| 91精品国产综合久久香蕉的特点| 日韩欧美一区二区在线视频| 精品国产成人系列| 国产精品久久二区二区| 樱桃视频在线观看一区| 免费在线观看一区二区三区| 国产在线精品不卡| va亚洲va日韩不卡在线观看| 欧美日韩一区在线| 久久女同互慰一区二区三区| 中文字幕一区二区三| 日韩国产欧美在线播放| 国产高清精品久久久久| 日本精品一级二级| 精品久久人人做人人爰| 国产精品你懂的在线| 午夜伊人狠狠久久| 粉嫩欧美一区二区三区高清影视| 在线观看日韩高清av| 欧美不卡一区二区三区| 综合自拍亚洲综合图不卡区| 丝袜美腿一区二区三区| 99re成人在线| 精品少妇一区二区三区在线播放| 亚洲欧洲日韩女同| 国产自产v一区二区三区c| 欧美日韩国产片| 欧美国产乱子伦| 看电影不卡的网站| 在线免费观看日本欧美| 国产精品伦理一区二区| 日本欧美在线看| 欧美综合色免费| 中文字幕一区二区三区在线不卡|