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

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

?? ch16.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
<!-- This document was created from RTF source by rtftohtml version 3.0.1 -->

	<META NAME="GENERATOR" Content="Symantec Visual Page 1.0">
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
	<TITLE>Teach Yourself C++ in 21 Days</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<H1 ALIGN="CENTER"><A HREF="ch15.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/htm/ch15.htm"><IMG SRC="../buttons/BLANPREV.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANPREV.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A><A HREF="javascript:if(confirm('http://www.mcp.com/sams  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.mcp.com/sams'" tppabs="http://www.mcp.com/sams"><IMG
SRC="../buttons/BLANHOME.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANHOME.GIF" WIDTH="37" HEIGHT="37" ALIGN="BOTTOM"
BORDER="0"></A><A HREF="../index.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/index.htm"><IMG SRC="../buttons/BLANTOC.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANTOC.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A><A HREF="ch17.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/htm/ch17.htm"><IMG SRC="../buttons/BLANNEXT.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANNEXT.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A></H1>
<H1></H1>

<UL>
	<LI><A HREF="#Heading1">Day 16</A>
	<UL>
		<LI><A HREF="#Heading2">Streams</A>
		<UL>
			<LI><A HREF="#Heading3">Overview of Streams</A>
			<UL>
				<LI><A HREF="#Heading4">Encapsulation</A>
				<UL>
					<LI><A HREF="#Heading5">Figure 16.1.</A>
				</UL>
				<LI><A HREF="#Heading6">Buffering</A>
				<UL>
					<LI><A HREF="#Heading7">Figure 16.2.</A>
					<LI><A HREF="#Heading8">Figure 16.3.</A>
					<LI><A HREF="#Heading9">Figure 16.4.</A>
					<LI><A HREF="#Heading10">Figure 16.5.</A>
				</UL>
			</UL>
			<LI><A HREF="#Heading11">Streams and Buffers</A>
			<LI><A HREF="#Heading12">Standard I/O Objects</A>
			<LI><A HREF="#Heading13">Redirection</A>
			<LI><A HREF="#Heading14">Input Using cin</A>
			<LI><A HREF="#Heading15">Listing 16.1. cin handles different data types</A><A HREF="#Heading16">.</A>
			<UL>
				<LI><A HREF="#Heading17">Strings</A>
				<LI><A HREF="#Heading18">String Problems</A>
			</UL>
			<LI><A HREF="#Heading19">Listing 16.2. Trying to write more than one word to cin</A><A
			HREF="#Heading20">.</A>
			<LI><A HREF="#Heading21">Listing 16.3. Multiple input</A><A HREF="#Heading22">.</A>
			<UL>
				<LI><A HREF="#Heading23">operator&gt;&gt; Returns a Reference to an istream Object</A>
			</UL>
			<LI><A HREF="#Heading24">Other Member Functions of cin</A>
			<UL>
				<LI><A HREF="#Heading25">Single Character Input</A>
			</UL>
			<LI><A HREF="#Heading26">Listing 16.4. Using get() with no parameters.</A>
			<LI><A HREF="#Heading27">Listing 16.5 Using get() with parameters.</A>
			<UL>
				<LI><A HREF="#Heading28">Getting Strings from Standard Input</A>
			</UL>
			<LI><A HREF="#Heading29">Listing 16.6. Using get() with a character array</A>
			<LI><A HREF="#Heading30">.</A>
			<LI><A HREF="#Heading31">Listing 16.7. Using getline().</A>
			<UL>
				<LI><A HREF="#Heading32">Using cin.ignore()</A>
			</UL>
			<LI><A HREF="#Heading33">Listing 16.8. Using ignore().</A>
			<UL>
				<LI><A HREF="#Heading34">peek() and putback()</A>
			</UL>
			<LI><A HREF="#Heading35">Listing 16.9. Using peek() and putback().</A>
			<LI><A HREF="#Heading36">Output with cout</A>
			<UL>
				<LI><A HREF="#Heading37">Flushing the Output</A>
			</UL>
			<LI><A HREF="#Heading38">Related Functions</A>
			<LI><A HREF="#Heading39">Listing 16.10. Using put().</A>
			<LI><A HREF="#Heading40">Listing 16.11. Using write().</A>
			<LI><A HREF="#Heading41">Manipulators, Flags, and Formatting Instructions</A>
			<UL>
				<LI><A HREF="#Heading42">Using cout.width()</A>
			</UL>
			<LI><A HREF="#Heading43">Listing 16.12. Adjusting the width of output.</A>
			<UL>
				<LI><A HREF="#Heading44">Setting the Fill Characters</A>
			</UL>
			<LI><A HREF="#Heading45">Listing 16.13. Using fill()</A><A HREF="#Heading46">.</A>
			<UL>
				<LI><A HREF="#Heading47">Set Flags</A>
			</UL>
			<LI><A HREF="#Heading48">Listing 16.14. Using setf.</A>
			<LI><A HREF="#Heading49">Streams Versus the printf() Function</A>
			<LI><A HREF="#Heading50">Listing 16.15. Printing with printf().</A>
			<LI><A HREF="#Heading51">File Input and Output</A>
			<LI><A HREF="#Heading52">ofstream</A>
			<UL>
				<LI><A HREF="#Heading53">Condition States</A>
				<LI><A HREF="#Heading54">Opening Files for Input and Output</A>
			</UL>
			<LI><A HREF="#Heading55">Listing 16.16. Opening files for read and write</A><A HREF="#Heading56">.</A>
			<UL>
				<LI><A HREF="#Heading57">Changing the Default Behavior of ofstream on Open</A>
			</UL>
			<LI><A HREF="#Heading58">Listing 16.17. Appending to the end of a file</A>
			<LI><A HREF="#Heading59">.</A>
			<LI><A HREF="#Heading60">Binary Versus Text Files</A>
			<LI><A HREF="#Heading61">Listing 16.18. Writing a class to a file</A><A HREF="#Heading62">.</A>
			<LI><A HREF="#Heading63">Command-Line Processing</A>
			<LI><A HREF="#Heading64">Listing 16.19. Using command-line arguments</A><A HREF="#Heading65">.</A>
			<LI><A HREF="#Heading66">Listing 16.20. Using command-line arguments.</A>
			<LI><A HREF="#Heading67">Summary</A>
			<LI><A HREF="#Heading68">Q&amp;A</A>
			<LI><A HREF="#Heading69">Workshop</A>
			<UL>
				<LI><A HREF="#Heading70">Quiz</A>
				<LI><A HREF="#Heading71">Exercises</A>
			</UL>
		</UL>
	</UL>
</UL>

<P>
<HR SIZE="4">

<H2 ALIGN="CENTER"><A NAME="Heading1"></A><FONT COLOR="#000077">Day 16</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2"></A><FONT COLOR="#000077">Streams</FONT></H2>
<P>Until now, you've been using <TT>cout</TT> to write to the screen and <TT>cin</TT>
to read from the keyboard, without a full understanding of how they work. Today,
you will learn

<UL>
	<LI>What streams are and how they are used.
	<P>
	<LI>How to manage input and output using streams.
	<P>
	<LI>How to write to and read from files using streams.
</UL>

<H3 ALIGN="CENTER"><A NAME="Heading3"></A><FONT COLOR="#000077">Overview of Streams</FONT></H3>
<P>C++ does not, as part of the language, define how data is written to the screen
or to a file, nor how data is read into a program. These are clearly essential parts
of working with C++, however, and the standard C++ library now includes the <TT>iostream</TT>
library, which facilitates input and output (I/O).</P>
<P>The advantage of having the input and output kept apart from the language and
handled in libraries is that it is easier to make the language &quot;platform-independent.&quot;
That is, you can write C++ programs on a PC and then recompile them and run them
on a Sun Workstation. The compiler manufacturer just supplies the right library,
and everything works. At least that's the theory.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>A library is a collection of OBJ
	files that can be linked to your program to provide additional functionality. This
	is the most basic form of code reuse, and has been around since ancient programmers
	chiseled 1s and 0s into the walls of caves. 
<HR>


</BLOCKQUOTE>

<H4 ALIGN="CENTER"><A NAME="Heading4"></A><FONT COLOR="#000077">Encapsulation</FONT></H4>
<P>The <TT>iostream</TT> classes view the flow of data from your program to the screen
as being a stream of data, one byte following another. If the destination of the
stream is a file or the screen, the source is usually some part of your program.
If the stream is reversed, the data can come from the keyboard or a disk file and
be &quot;poured&quot; into your data variables.</P>
<P>One principal goal of streams is to encapsulate the problems of getting the data
to and from the disk or the screen. Once a stream is created, your program works
with the stream and the stream sweats the details. Figure 16.1 illustrates this fundamental
idea.<BR>
<BR>
<A NAME="Heading5"></A><A HREF="javascript:if(confirm('http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp01.jpg  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?'))window.location='http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp01.jpg'" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp01.jpg"><FONT COLOR="#000077">Figure
16.1.</FONT></A><FONT COLOR="#000077"> </FONT><I>Encapsulation through streams.</I>
<H4 ALIGN="CENTER"><A NAME="Heading6"></A><FONT COLOR="#000077">Buffering</FONT></H4>
<P>Writing to the disk (and to a lesser extent the screen) is very &quot;expensive.&quot;
It takes a long time (relatively speaking) to write data to the disk or to read data
from the disk, and execution of the program is generally blocked by disk writes and
reads. To solve this problem, streams provide &quot;buffering.&quot; Data is written
into the stream, but it is not written back out to the disk immediately. Instead,
the stream's buffer fills and fills, and when it is full it writes to the disk all
at once.</P>
<P>Picture water trickling into the top of a tank, and the tank filling and filling,
but no water running out of the bottom. Figure 16.2 illustrates this idea.</P>
<P>When the water (data) reaches the top, the valve opens and all the water flows
out in a rush. Figure 16.3 illustrates this.</P>
<P>Once the buffer is empty, the bottom valve closes, the top valve opens, and more
water flows into the buffer tank. Figure 16.4 illustrates this.</P>
<P>Every once in a while you need to get the water out of the tank even before it
is full. This is called &quot;flushing the buffer.&quot; Figure 16.5 illustrates
this idea.<BR>
<BR>
<A NAME="Heading7"></A><A HREF="javascript:if(confirm('http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02a.jpg  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?'))window.location='http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02a.jpg'" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02a.jpg"><FONT COLOR="#000077">Figure
16.2.</FONT></A><FONT COLOR="#000077"> </FONT><I>Filling the buffer.</I><BR>
<BR>
<A NAME="Heading8"></A><A HREF="javascript:if(confirm('http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02b.jpg  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?'))window.location='http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02b.jpg'" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02b.jpg"><FONT COLOR="#000077">Figure
16.3.</FONT></A><FONT COLOR="#000077"> </FONT><I>Emptying the buffer</I>.<BR>
<BR>
<A NAME="Heading9"></A><A HREF="javascript:if(confirm('http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02c.jpg  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?'))window.location='http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02c.jpg'" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02c.jpg"><FONT COLOR="#000077">Figure
16.4.</FONT></A><FONT COLOR="#000077"> </FONT><I>Refilling the buffer.</I><BR>
<BR>
<A NAME="Heading10"></A><A HREF="javascript:if(confirm('http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02d.jpg  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?'))window.location='http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02d.jpg'" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/art/ch16/16zcp02d.jpg"><FONT COLOR="#000077">Figure
16.5.</FONT></A><FONT COLOR="#000077"> </FONT><I>Flushing the buffer.</I>
<H3 ALIGN="CENTER"><A NAME="Heading11"></A><FONT COLOR="#000077">Streams and Buffers</FONT></H3>
<P>As you might expect, C++ takes an object-oriented view toward implementing streams
and buffers.

<UL>
	<LI>The <TT>streambuf</TT> class manages the buffer, and its member functions provide
	the capability to fill, empty, flush, and otherwise manipulate the buffer.
	<P>
	<LI>The <TT>ios</TT> class is the base class to the input and output stream classes.
	The <TT>ios</TT> class has a <TT>streambuf</TT> object as a member variable.
	<P>
	<LI>The <TT>istream</TT> and <TT>ostream</TT> classes derive from the <TT>ios</TT>
	class and specialize input and output stream behavior, respectively.
	<P>
	<LI>The <TT>iostream</TT> class is derived from both the <TT>istream</TT> and the
	<TT>ostream</TT> classes and provides input and output methods for writing to the
	screen.
	<P>
	<LI>The <TT>fstream</TT> classes provide input and output from files.
</UL>

<H3 ALIGN="CENTER"><A NAME="Heading12"></A><FONT COLOR="#000077">Standard I/O Objects</FONT></H3>
<P>When a C++ program that includes the <TT>iostream</TT> classes starts, four objects
are created and initialized:


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>The <TT>iostream</TT> class library
	is added automatically to your program by the compiler. All you need to do to use
	these functions is to put the appropriate <TT>include</TT> statement at the top of
	your program listing. 
<HR>


</BLOCKQUOTE>


<UL>
	<LI><TT>cin</TT> (pronounced &quot;see-in&quot;) handles input from the standard
	input, the keyboard.
	<P>
	<LI><TT>cou</TT> (pronounced &quot;see-out&quot;) handles output to the standard
	output, the screen.
	<P>
	<LI><TT>cer</TT> (pronounced &quot;see-err&quot;) handles unbuffered output to the
	standard error device, the screen. Because this is unbuffered, everything sent to

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
波多野结衣精品在线| 国产精品99久久久久久久女警| 国产精品久久久久久久久久免费看| 日韩精品一区国产麻豆| 日韩一级大片在线观看| 欧美一级爆毛片| 欧美电影免费观看高清完整版在线观看 | 国产婷婷色一区二区三区| 精品久久久三级丝袜| 久久久综合激的五月天| 国产欧美精品一区aⅴ影院| 中文在线一区二区| 亚洲三级在线免费| 亚洲va欧美va天堂v国产综合| 天天综合网天天综合色| 久久精品国产精品亚洲红杏| 国产在线视频精品一区| aa级大片欧美| 欧美日韩一区二区欧美激情| 日韩精品中文字幕在线一区| 欧美国产精品中文字幕| 亚洲综合久久久久| 精品亚洲国产成人av制服丝袜| 成人午夜视频在线观看| 欧美色偷偷大香| 精品国产一区二区三区久久久蜜月| 久久久久久综合| 一区二区三区欧美视频| 韩国av一区二区三区在线观看| 91社区在线播放| 日韩欧美美女一区二区三区| 国产精品乱码妇女bbbb| 亚洲成精国产精品女| 国产一区二区成人久久免费影院| 色噜噜狠狠色综合中国| 2024国产精品| 亚洲国产精品嫩草影院| 久久国产精品99久久人人澡| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美日韩午夜影院| 日本一区二区三区国色天香| 日韩国产精品久久久久久亚洲| 不卡av免费在线观看| 日韩三级中文字幕| 亚洲精品videosex极品| 国产盗摄精品一区二区三区在线| 欧美女孩性生活视频| 日韩理论片在线| 国产91丝袜在线播放九色| 欧美日韩国产小视频| 国产精品毛片久久久久久久| 久久精品av麻豆的观看方式| 欧美日韩综合色| 亚洲人成小说网站色在线| 国产成人在线视频网站| 5858s免费视频成人| 一区二区三区欧美| 成人精品视频.| 国产欧美综合在线| 国产成人综合亚洲91猫咪| 欧美一区二区免费视频| 天天av天天翘天天综合网色鬼国产| 91丨九色丨国产丨porny| 久久久国产午夜精品| 美女视频第一区二区三区免费观看网站 | 日韩一区二区在线观看视频 | 久久精品国产亚洲a| 欧美日韩国产小视频在线观看| 亚洲免费成人av| 91同城在线观看| 最新中文字幕一区二区三区| 99免费精品视频| 国产精品人妖ts系列视频| 国产成人综合自拍| 日本一区二区久久| 免费在线观看一区二区三区| 首页欧美精品中文字幕| 五月天丁香久久| 亚洲视频小说图片| 国产精品456露脸| 久久一区二区三区四区| 久久久欧美精品sm网站| 91网站在线播放| 国产专区欧美精品| 性感美女久久精品| 中文字幕日韩一区| 久久综合资源网| 欧美性videosxxxxx| 91丨porny丨国产| 国产老妇另类xxxxx| 日本免费新一区视频| 亚洲精品国产a| 国产精品久久久久久久久免费樱桃 | 欧美午夜精品电影| 国产不卡免费视频| 青青草国产成人99久久| 亚洲小说春色综合另类电影| 亚洲欧美一区二区视频| 国产欧美日韩精品在线| 久久综合色8888| 精品精品欲导航| 日韩一区二区三| 欧美一级日韩免费不卡| 91.成人天堂一区| 欧美色男人天堂| 欧美视频中文字幕| 欧美日韩在线播| 欧美久久久一区| 欧美人与性动xxxx| 欧美日韩大陆一区二区| 欧美巨大另类极品videosbest| 在线亚洲精品福利网址导航| 色哟哟亚洲精品| 在线国产电影不卡| 欧美三区免费完整视频在线观看| 欧美视频精品在线观看| 欧美午夜电影网| 欧美日韩精品电影| 欧美一区二区播放| 日韩午夜在线播放| 久久久久久一级片| 中文字幕精品三区| 亚洲欧洲国产日韩| 亚洲h精品动漫在线观看| 午夜精品福利一区二区三区av| 婷婷夜色潮精品综合在线| 日本va欧美va精品发布| 精品亚洲成a人| 成人手机在线视频| 欧美影院精品一区| 欧美第一区第二区| 国产精品伦理在线| 亚洲精品国产a| 蜜桃久久久久久| 久久91精品久久久久久秒播| 国产成人av电影在线观看| 99久久免费精品高清特色大片| 在线观看日韩毛片| 日韩欧美国产电影| 国产精品视频你懂的| 亚洲尤物在线视频观看| 蜜臀av性久久久久蜜臀aⅴ流畅 | 一区二区成人在线| 免费人成网站在线观看欧美高清| 狠狠色丁香久久婷婷综| 91视视频在线观看入口直接观看www | 亚洲少妇30p| 日本麻豆一区二区三区视频| 国产福利一区在线观看| 欧美日韩三级在线| 久久女同互慰一区二区三区| 亚洲人亚洲人成电影网站色| 免费高清在线一区| voyeur盗摄精品| 日韩欧美一区二区在线视频| 国产精品毛片久久久久久久| 日韩影院精彩在线| 99精品久久只有精品| 日韩欧美国产不卡| 一区二区三区精品在线观看| 久久91精品久久久久久秒播| 欧美视频三区在线播放| 国产精品人妖ts系列视频| 美女一区二区三区在线观看| 色呦呦一区二区三区| 欧美国产日韩亚洲一区| 奇米影视在线99精品| 91国在线观看| 国产精品久久国产精麻豆99网站 | 精品少妇一区二区三区在线播放 | 东方aⅴ免费观看久久av| 91.com视频| 一区二区三区精品| 成人美女在线视频| 久久久综合激的五月天| 日韩一区精品字幕| 欧美日韩中字一区| 中文字幕永久在线不卡| 国产一区二区三区在线观看精品 | 成人免费高清在线观看| 欧美xxxxx裸体时装秀| 亚洲高清三级视频| 色婷婷国产精品| 国产精品久久久久久亚洲毛片 | 欧美国产禁国产网站cc| 另类调教123区 | 亚洲丝袜美腿综合| 成人夜色视频网站在线观看| 日韩欧美一区中文| 麻豆一区二区三区| 欧美一区二区三区不卡| 亚洲成人免费视| 欧美在线观看18| 亚洲一二三区视频在线观看| 色综合天天综合网天天看片| 中文字幕一区二区三区在线不卡| 国产成人午夜电影网| 国产欧美日韩视频在线观看| 国产精品一色哟哟哟| 国产亚洲欧洲一区高清在线观看|