A First Look At Input/Output
2012-10-22 21:25
330 查看
1.stream
A stream is a sequence of characters intended to be read from or written to an I/O device of some kind. The term "stream" is intended to suggest that the characters
are generated, or consumed, sequentially over time.
2.standard input and output objects
The library defines four IO objects:
cin
(standard input)
cout
(standard output)
cerr
(standard error)
clog
(for general information about the execution of the program)
3.#include preprocessor directive
The
#include directive must be written on a single line - the name of the header and the#include must appear on the same line.
4. output operator <<
The output operator writes its right-hand operand to the ostream that is its left-hand operand.
The result is the value of its left-hand operand. This fact allows us to chain together output requests.For example,
cout<<"enter two numbers:";
cout<<endl;
=
(cout<<"enter two numbers:")<<endl;
=
cout<<"enter two numbers:"<<endl;
5.input operator >>
It reads from its
istream operand and stores the value it read in its right-hand operand.
The input operator returns its left-hand operand as its result. Thus, we can combine a sequence of input requests into a single statement. For example,
cin>>v1;
cin>>v2;
=
cin>>v1>>v2;
如果输入的是:2,8,那么执行中cin的流字符如下:
cin>>v1;
//cin(2,8)
cin>>v2;
//cin(8)
第一句执行完成后,流字符中的2就被consumed了。
6.The iostream library defines versions of the input and output operators that accept all of the built-in
types.
That's the concept behind the following statement:
cout<<"the sum of "<<v1<<"and"<<v2<<"is "<<v1+v2<<endl;
A stream is a sequence of characters intended to be read from or written to an I/O device of some kind. The term "stream" is intended to suggest that the characters
are generated, or consumed, sequentially over time.
2.standard input and output objects
The library defines four IO objects:
cin
(standard input)
cout
(standard output)
cerr
(standard error)
clog
(for general information about the execution of the program)
3.#include preprocessor directive
The
#include directive must be written on a single line - the name of the header and the#include must appear on the same line.
4. output operator <<
The output operator writes its right-hand operand to the ostream that is its left-hand operand.
The result is the value of its left-hand operand. This fact allows us to chain together output requests.For example,
cout<<"enter two numbers:";
cout<<endl;
=
(cout<<"enter two numbers:")<<endl;
=
cout<<"enter two numbers:"<<endl;
5.input operator >>
It reads from its
istream operand and stores the value it read in its right-hand operand.
The input operator returns its left-hand operand as its result. Thus, we can combine a sequence of input requests into a single statement. For example,
cin>>v1;
cin>>v2;
=
cin>>v1>>v2;
如果输入的是:2,8,那么执行中cin的流字符如下:
cin>>v1;
//cin(2,8)
cin>>v2;
//cin(8)
第一句执行完成后,流字符中的2就被consumed了。
6.The iostream library defines versions of the input and output operators that accept all of the built-in
types.
That's the concept behind the following statement:
cout<<"the sum of "<<v1<<"and"<<v2<<"is "<<v1+v2<<endl;
相关文章推荐
- Expected one of #, input, filter, output at line 2, column 1 (byte 2): Logstash
- A first look at Xync Lync client on iOS iPhone/iPad
- First Look at Silverlight 2--Part4:使用CSS风元素封装页面外观风格
- First Look At .NET 2.0
- A First Look at Rust Language
- A First Look at IIS 7.0 /Indigo -from VSLive!
- A First Look at Rust Language
- logstash启动报配置文件错误Expected one of #, input, filter, output at line 1, column 1 (byte 1) after
- A First Look at ASP.NET v. 2.0
- 【存储管理】请求淘汰换页算法先进先出算法(first input first output,FIFO)
- Linux下“read failed after 0 of 4096 at 0: Input/output error”
- reason=>"Expected one of #, input, filter, output at line 1, column 1 (byte 1) after "}
- A first look at ADO. NET and System. Xml v. 2. 0
- A first hand look at building an Android application
- A First Look at ObjectSpaces in Visual Studio "Whidbey".
- A First Look at the Android Testing Framework
- First Look at Silverlight 2--Part1:使用VS2008和Silverlight2创建HelloWorld程序
- First Look at Silverlight 2--Part5 使用ListBox显示列表数据
- A First Look at SQL Server 2005 for Developers:Introduction
- BizTalk 2006 R2 First Look at the WCF Adapter