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