To accept a string or a line of input stream as input, we have an in-built function called getline(). This function is under the <string> header file. It accepts all the strings until a newline character is encountered. istream& getline (istream& is, string& str, char delim);
The C++ getline() is a standard library function that is used to read a string or a line from an input stream. It is a part of the <string> header. The getline() function extracts characters from the input stream and appends it to the string object until the delimiting character is encountered.
I'm trying to store the input that user enters through console. so I need to include the "enter" and any white space.
But cin
stops giving me input after the first space.
Is there a way to read whole lines until CTRL+Z is pressed, or something?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With