C + + global function Std::getline

Source: Internet
Author: User

Tag: line exists without input stream false ETL standard BSP STR

Often use Getline to read the file, but found that for C and C + + getline before a very deep understanding, here to draw on some information on the web to summarize.

1, in the standard C language, the Getline function does not exist. In the GCC compiler, the standard C library has been extended to include a getline function.

2. Although there is no getline function in the standard C language, there is a fgets function with the same function. The Fgets function is a C-style read-by-line function that reads in a newline character and is also convenient to use. It is recommended in C code to use this function to read rows.

3. Global function Getline in C + + standard library.

getline function function description in C + + standard library

Reads a line from the input stream into string s

? Function: – reads characters from the input stream and saves to a string variable – until the following occurs:? Read the file End flag? read a new Line – if Getline does not read the character, it will return false, which can be used to determine whether the file ends 4, C + + The Getline function that reads a line in a row is not read into a newline character, whereas the Getline function and fgets of the GCC compiler extension in the C language are read in line breaks.

Summarize:

Read the file by line in the C + + global function Std::getline it, simple and convenient.

C + + global function Std::getline

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.