1.get
istream& get ( char& c );
istream& get ( char* s, streamsize n );
istream& get ( char* s, streamsize n, char delim );
istream& get ( streambuf& sb);
istream& get ( streambuf& sb, char delim );
Get unformatted data from stream
These member functions perform unformatted input operations. Depending on the type and number of arguments the function behaves in the following way:
istream& get ( char& c );
Extracts a character from the stream and stores it in c.
istream& get (char* s, streamsize n );
Extracts characters from the stream and stores them as a c-string into the array beginning at s. Characters are extracted until either (n – 1) characters have been extracted or the delimiting character ‘\n’ is found. The extraction also stops if the end of file is reached in the input sequence or if an error occurs during the input operation.
If the delimiting character is found, it is not extracted from the input sequence and remains as the next character to be extracted. Use getline if you want this character to be extracted (and discarded).
The ending null character that signals the end of a c-string is automatically appended at the end of the content stored in s.istream& get (char* s, streamsize n, char delim );
Same as above, except that the delimiting character is the one specified indelim instead of ‘\n’.
istream& get (streambuf& sb);
Extracts characters from the stream and inserts them in the stream buffer sb until either the delimiting character ‘\n’ is found or end of file is reached. The extraction also stops if an error occurs either in the input sequence controled by the stream or in the output sequence controlled by sb.
istream& get (streambuf& sb, char delim );
Same as above, except that the delimiting character is the one specified indelim instead of ‘\n’.The number of characters read by any of the previous input operations can be obtained by calling to the member function gcount.
Parameters
c
A char variable to store the extracted character.
s
A pointer to an array of characters where the string is stored as a c-string
n
Maximum number of characters to store (including the ternimating null character).
This is an integer value of type streamsize.
delim
The delimiting character. The operation of extracting succesive characters is stopped when this character is read. This parameter is optional, if not specified the function considers ‘\n’ (a newline character) to be the delimiting character.
sb
An output stream buffer (an object of class streambuf or any of its derived classes).
2.getline
istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );
Extracts characters from the input sequence and stores them as a c-string into the array beginning at s.
Characters are extracted until either (n – 1) characters have been extracted or the delimiting character is found (which is delim if this parameter is specified, or ‘\n’ otherwise). The extraction also stops if the end of file is reached in the input sequence or if an error occurs during the input operation.If the delimiter is found, it is extracted and discarded, i.e. it is not stored and the next input operation will begin after it. If you don’t want this character to be extracted, you can use member get instead.The ending null character that signals the end of a c-string is automatically appended to s after the data extracted.The number of characters read by this function can be obtained by calling to the member function gcount.
Parameters
s
A pointer to an array of characters where the string is stored as a c-string.
n
Maximum number of characters to store (including the terminating null character).
This is an integer value of type streamsize.
If the function stops reading because this size is reached, the failbit internal flag is set.
delim
The delimiting character. The operation of extracting succesive characters is stopped when this character is read. This parameter is optional, if not specified the function considers ‘\n’ (a newline character) to be the delimiting character.
3.ignore
istream& ignore ( streamsize n = 1, int delim = EOF );
Extract and discard characters
Extracts characters from the input sequence and discards them.The extraction ends when n characters have been extracted and discarded or when the character delim is found, whichever comes first. In the latter case, the delim character itself is also extracted.
Parameters
n
Maximum number of characters to extract (and ignore).
This is an integer value of type streamsize.
delim
Delimiting character.
4.peekint peek ( );
Peek next character
Reads and returns the next character without extracting it, i.e. leaving it as the next character to be extracted from the stream.
5.gcount
streamsize gcount ( ) const;
Get number of characters extracted by last unformatted input operation
Returns the number of characters extracted by the last unformatted input operation performed on the object.The unformatted input operations that modify the value returned by this function are those performed by the following member functions: get, getline, ignore, peek, read, readsome, putback and unget.Notice though, that peek, putback and unget do not extract characters. So gcount will always return zero after a call to any of these.
PS:以上内容全部来至www.CPlusPlus.com。
了解更多可以查看:http://www.cplusplus.com/reference/iostream/istream/
Extraordinary job! The data given was very helpful. I hope you carry on the great job performed.
Hialeah FL Locksmith
This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!
哥表示哥是文盲 根本没看懂……
呵呵,搞编程的,英语得学好。
[s:30] 英文、、我英文不过关啊、、看来得多学习学习了、、 [s:19]
你至少翻译一下呗,虽然我不看,但是别人要看啊,呵呵
@C瓜哥, 你看MSDN是怎么看的?
@Tanky Woo,
睁开眼睛看,看完闭眼,默念三声咒语
@Tanky Woo,
其实我的意思是: 直接抄过来叫转载; 如果翻译一下,就是自己的原创文章了,知道了吗? [s:6]
@C瓜哥, 这是真真的真理,多多翻译哈
@Vinceen, 是啊,虽然勉强看得懂,但很容易漏掉某些东西,毕竟不是自己的母语。正因为这样,印度的软件业就比我们的好。
@vanxining, 不过总有很多英语牛人,但那些牛人又有多少搞IT的呢,看汉文最舒服。
不过很多知识既然是从外面来的,没有人搞翻译的话,就只能去复习英语了。
@C瓜哥, 汗。瓜哥,你没看完全文 [s:32]
我最后写了“PS:以上内容全部来至www.CPlusPlus.com。
了解更多可以查看:http://www.cplusplus.com/reference/iostream/istream/ ”
我感觉这些东西,如果被翻译了,肯定会造成理解上的困难,搞编程,学英语是必不可少的。
再次把瓜哥砸一下,居然说哥抄袭。。。 [s:32]
@Tanky Woo,
编程讲的是思想,而不受种某种自然语言限制(如果可以,你也可以把它翻译成蒙语)
你把别人的思想讲解一下的能力都没有吗?呵呵 [s:6]
@C瓜哥, 汗了。瓜哥你就别绕了。
其实都知道看编程类书籍不但要看国外的,而且最好看原版,不翻译的。
再说了我这只是为了自己学习。。。我能看懂就行了。。。。干嘛要翻译。。。。
再次砸瓜![s:32] [s:8]
@Tanky Woo,
好,我不绕了,哈哈 [s:6]
@C瓜哥, [s:32]
唉,最近郁闷死了,前天早上的考试基本废了。今天上午上课又点名了,那时我还在寝室欢快的折腾博客在。。。。
@Tanky Woo,
哥最骄傲的事情是,上学期有门选修课看错了考试时间,结果缺考了
@C瓜哥,
你比哥还牛掰。。。
加油吧,我这几天把随机算法连载写完可能也得消停了。毕竟这学期专业课还是很多的。
@C瓜哥, 可惜我也不看,我看不懂啊! [s:5]
一大串字母啊。太头疼了。
@wmtimes, =。=。。。
推荐一个好网站:http://www.cprogramming.com
@Dawnson, 谢谢啊!以后有啥好资源多分享下哈! [s:4]
这篇文章其实关键是那几个方法的声明,其它的都是浮云。所以英文不好的人也是可以看的。
真够狠的,E文这么好的说…… [s:5]
一天更新了兩章。。。 [s:21]
@kita, 哈哈,给力啊!我也去顶!
怎么没翻译过来啊!
@yalonzh, 汗,翻译了就变味了,编程技术还是看国外原版资料比较好。。
确实不懂。 [s:11]
@趣嗖嗖, 别哭。。。。用有道电子词典就行了,嘿嘿。
Tanky Woo你好狠啊,不過好像裡面的英文比較通俗易懂 [s:8]
@kita, kita施主,让您受惊了。。。。 [s:6]
@Tanky Woo, 嘻嘻,開頭看了還好,好歹以前經常跑去看國外的tutorials
@kita, [2:23]
@Tanky Woo, 開始折騰ajax
@kita, Orz… [s:28]