Can someone explain the purpose of this function?
Can someone explain the purpose of this function?
>Can someone explain the purpose of this function?
I would think the purpose to be pretty straight forward, it gets a line from input.
-Prelude
My best code is written with the delete key.
getline() will store inputs from the stream until '\n'.
Kuphryn
the insertion operator >> is used to input data into a variable from the input buffer. It ignores leading whitespace, inputs nonwhite space data into the variable, and then stops input at the next whitespace data, but doesn't remove the terminating whitespace data from the input buffer. If the input is into a char buffer it automatically adds the terminating null char to the end of the valid input.
getline() doesn't ignore leading whitespace. It inputs all material in the input buffer into a string buffer up to a given number of char inputs or until a terminating char is identified. The terminating char defaults to the new line char. The terminating char, if found, is removed from the buffer. The null char is automatically added to the end of the string buffer input. getline() has two main variants:
//to be used with C style strings
istreamName.getline(bufferName, MaxNumCharToRead, 'terminatingChar');
//to be used with STL strings
getline(istreamName, STLstringName, 'terminatingChar');