C++:io Buffer

Source: Internet
Author: User

1. C + + Each stream object maintains a buffer, which is essentially a character array for storing input and output sequences, and is described by three pointers (Begin_pointer,next_pointer,end_pointer), which are divided into full buffers by the refresh type. Row buffers and unbuffered. (see "C + + input and output stream and localization" for details)

2. Commonly used buffer functions

Function

Role

int Peek ()

Returns the next character in the buffer, and the pointer does not move back

void get (char ch)

Assigns the next character of the buffer to CH, and the pointer moves back

Char get ()

The next character of the buffer is taken out and returned, and the pointer moves back

void putback (char ch)

Puts a function that was previously read from the stream back into the buffer and inserts it into the current pointer position

IStream &ignore (streamsize num=1, int delim=eof)

Ignoring the next num characters or encountering Delim early end, Delim is also ignored

int sync ()

Clears the buffer associated with the stream, returns 0 for success, 1 for failure

istream& seekg (Streampos POS)

Sets the position of the input stream pointer to POS, POS is the absolute position

istream& seekg (Streamoff off, Ios_base::seekdir)

Setting the input stream pointer to the position relative to the path offset off, Ios_base::seekdir can take the following constants: Ios::beg (buffer start), ios::cur (current position), ios::end (end of buffer)

Streampos Tellg ()

Returns the current position of the pointer

ostream& SEEKP (Streampos pos) and ostream& SEEKP (Streamoff off, Ios_base::seekdir)

Similar to SEEKG for input stream objects

Streampos TELLP ()

Similar to TELLG for output stream objects

C++:io Buffer

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.