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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中国av一区二区三区| 亚洲午夜精品久久久久久久久| 成人国产视频在线观看| 国产精品久久久久久久久免费桃花| 高清不卡一区二区在线| 国产精品麻豆欧美日韩ww| 99久久99久久综合| 亚洲国产精品人人做人人爽| 91麻豆精品国产91久久久| 久久国产剧场电影| 国产婷婷一区二区| 一道本成人在线| 日本伊人午夜精品| 久久天堂av综合合色蜜桃网| www.亚洲精品| 亚洲444eee在线观看| 欧美成人一区二区三区在线观看 | 国内久久婷婷综合| 欧美激情一区二区| 色狠狠色狠狠综合| 麻豆国产欧美日韩综合精品二区| 国产视频911| 欧美在线你懂的| 狠狠色狠狠色综合系列| 综合久久久久久| 91精品在线免费观看| 国产高清在线观看免费不卡| 亚洲视频一区二区在线观看| 欧美一区二区三区免费大片 | 中文字幕av一区 二区| 91在线视频18| 欧美国产一区在线| 国产综合久久久久久久久久久久| 亚洲国产成人在线| 欧美区一区二区三区| 国产尤物一区二区| 一区二区三区欧美日韩| 久久综合99re88久久爱| 色婷婷精品大视频在线蜜桃视频| 蜜桃在线一区二区三区| 欧美bbbbb| 亚洲欧美一区二区久久| 欧美一级片免费看| 99久久99久久精品免费看蜜桃 | 男男gaygay亚洲| 国产精品久久久久aaaa樱花 | 五月激情综合色| 国产欧美日韩不卡免费| 欧美裸体bbwbbwbbw| 成人免费视频一区| 久久精品国产亚洲高清剧情介绍| 中文字幕一区二区三区精华液| 欧美一区二区二区| 91免费观看视频| 国产精品综合久久| 日韩和欧美一区二区| 亚洲人吸女人奶水| 久久精品一区二区三区不卡 | 欧美巨大另类极品videosbest| 成人免费视频视频在线观看免费| 日韩av一级电影| 亚洲免费av在线| 国产喂奶挤奶一区二区三区| 日韩一卡二卡三卡四卡| 色婷婷激情久久| 成人免费视频播放| 国产一区二区三区四区五区入口| 亚洲bt欧美bt精品| 怡红院av一区二区三区| 欧美国产一区视频在线观看| 日韩久久精品一区| 欧美人伦禁忌dvd放荡欲情| 97久久精品人人澡人人爽| 国产精品一区二区在线播放 | 99久久免费视频.com| 国产精品一区三区| 久久99蜜桃精品| 视频在线观看一区二区三区| 综合电影一区二区三区| 国产色产综合色产在线视频| 欧美成人高清电影在线| 欧美美女黄视频| 欧美亚洲免费在线一区| 色综合中文字幕| 懂色av中文字幕一区二区三区| 久久er精品视频| 蜜桃视频在线观看一区| 一区二区免费视频| 欧美男生操女生| 一区二区三区在线免费播放| 欧美一卡在线观看| 东方aⅴ免费观看久久av| 韩国视频一区二区| 卡一卡二国产精品 | 中文字幕一区二区三区视频| 久久精品亚洲麻豆av一区二区 | 国产精品网站在线| 久久久99久久| 久久久欧美精品sm网站| 精品免费国产一区二区三区四区| 欧美一区二区三区免费观看视频| 欧美一区二区视频观看视频 | 日韩一区在线免费观看| 国产欧美综合在线| 国产女主播一区| 久久久久97国产精华液好用吗| 久久综合久久99| 久久综合九色综合欧美98| 久久这里都是精品| 久久精品综合网| 日本一区二区综合亚洲| 国产精品美女视频| 亚洲色图.com| 亚洲一区二区偷拍精品| 亚洲午夜精品网| 免费精品视频在线| 极品少妇一区二区三区精品视频 | 一区二区三区欧美视频| 国产·精品毛片| 久久尤物电影视频在线观看| 亚洲午夜久久久久久久久电影院| 97成人超碰视| 国产一区二区三区四区在线观看| 久久精品国产精品亚洲精品| 久久91精品久久久久久秒播| 国产一区二区在线观看免费| 高清不卡一区二区在线| 99久久久精品| 欧美日韩国产高清一区二区| 7777精品伊人久久久大香线蕉 | 欧美日韩精品综合在线| 91麻豆精品国产91| 久久午夜免费电影| 亚洲欧美自拍偷拍色图| 亚洲午夜精品17c| 久久成人免费日本黄色| 成人性生交大片免费看视频在线| 一本大道久久a久久精二百| 欧美日韩国产一级片| 久久久综合视频| 亚洲色图都市小说| 日日夜夜免费精品视频| 国产尤物一区二区在线| 97久久超碰精品国产| 欧美色综合网站| 精品国产青草久久久久福利| 中文字幕不卡三区| 亚洲成人av电影在线| 久久66热re国产| 99久久久久久99| 欧美一区二区大片| 国产精品嫩草久久久久| 亚洲国产欧美一区二区三区丁香婷| 亚洲成av人片在线观看无码| 精品91自产拍在线观看一区| 久久影院电视剧免费观看| 91精品国产aⅴ一区二区| 久久精品人人做人人爽人人| 亚洲色图制服丝袜| 日韩电影免费在线看| 成人激情av网| 在线播放日韩导航| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲综合成人在线| 国产一区二区看久久| 在线欧美小视频| 26uuu精品一区二区在线观看| 亚洲欧美日韩电影| 韩国av一区二区| 欧美午夜电影一区| 国产亚洲福利社区一区| 亚洲综合精品自拍| 国产黄色精品视频| 欧美精品一二三四| 国产精品久久久久久久久搜平片| 午夜精品福利一区二区蜜股av | 日韩午夜av电影| 亚洲丝袜精品丝袜在线| 久久不见久久见免费视频1| 91黄视频在线| 国产夜色精品一区二区av| 亚洲1区2区3区4区| 99国产精品久| 久久在线免费观看| 五月天激情综合网| 99re热这里只有精品视频| 精品久久久久久最新网址| 一卡二卡三卡日韩欧美| 国产成人亚洲综合a∨猫咪| 欧美一区二区视频在线观看2022| 亚洲乱码中文字幕综合| 国产成人一区在线| 日韩精品一区二区三区视频| 一区二区久久久久久| 色婷婷久久99综合精品jk白丝| 国产亚洲精品资源在线26u| 丝袜国产日韩另类美女| 国产乱码精品一区二区三| 中文字幕不卡在线观看| 日本一道高清亚洲日美韩|