Public member functions of the IStream class

Source: Internet
Author: User

1 eatwhite

2 Get

3 Getline

4 Gcount

5 Ignore

6 operator>>

7 Peek

8 Read

9 SEEKG

Ten TELLG

1 eatwhite

Ignore leading spaces

2 Gcount

Count the last characters entered

3 Get

Extracting characters from a stream, including spaces

Std::cin.get (CH);//equivalent to Ch=std::cin.get;

1#include <iostream>2 3 voidMain ()4 {5     CharCH =0;6 7      while(ch! ='\ t')8     {9 std::cout.put (CH);TenStd::cin.Get(CH);//equivalent to Ch=std::cin.get; One     } A  -System"Pause"); -}

Interview, compound expression

1#include <iostream>2 3 voidMain ()4 {5     CharCH =0;6 7      while(ch = std::cin.Get()) !='\ t')//Compound Expressions8     {9 std::cout.put (CH);Ten     } One          ASystem"Pause"); -}

4 Getline

Extracts a line of characters from a stream

Std::cin.getline (str, 10);//Limit length, save 10-1 = 9 characters, last character is ' + ', function: Limit the length of the input password, prevent buffer overflow

1#include <iostream>2 3 voidMain ()4 {5     Charstr[ -] = {0 };6 7Std::cin.getline (str,Ten);//Limit length, save 10-1 = 9 characters, last character is ' + ', function: Limit the length of the input password, prevent buffer overflow8 9Std::cout <<str;Ten              OneSystem"Pause"); A}

5 Ignore

Extracts and discards specified characters in a stream

6 operator>>

Extraction operators

7 Peek

Returns the next character in the stream, but does not remove it from the stream

8 Read

Unformatted Input byte count

9 SEEKG

Move the input stream pointer

Ten TELLG

Returns the pointer value for the specified position in the input stream

Public member functions of the IStream class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.