There are two getline functions in C + +, each defined in a different header file
1, getline () is defined in the <string> header file, the function is to take a line of string, read to the end of the newline character R, and discard the newline character, if you need to read the characters, then the next line read.
Getline (CIN,STR); The first argument is the input stream object, and the second argument is a string object that takes the IStream parameter as the return value. (Getline (CIN, line))
2, Cin.getline () is a member function of CIN, defined in the <iostream> header file, the function has two parameters, the first parameter is used to store the input row of the name of the array, the second parameter is to read the number of characters, if this parameter is 20, then the letter The number reads up to 19 characters, the remaining space is used to store the empty characters that are automatically added at the end, and the getline () member function stops reading the specified number of characters or encounters a newline character, as in the above, such as Cin.getline (name, 20);
3, Cin.get () There are two ways, the first is similar to Cin.getline (), they accept the same parameters, the same way to interpret the parameters, and all read to the end of the line, but get is not read and discard the newline character, but leave it in the input queue. If you finish a cin.get (name, size) and then use Cin.get (name, size), the new line is not read, only the newline character is read, and the second method is Cin.get () with no arguments, which reads a character, including newline characters.
Cin.getline (name, 20); with Cin.get (name,); Cin.get (); same effect
Cin.get (), Cin.getline (), getline () difference