Not quite. There are several problems with cin. It can lead to serious problems if the wrong data type is entered, and it leaves a newline character ('\n') in the input stream. This can cause problems when chaining input. Also, cin prevents you from more than one word. If I were to input "Hello, world!" and the data was collected using cin, then the string the data was stored in would only contain "Hello,". If you used getline instead, wherever the data was stored would contain the full message, "Hello, world!". Basically, avoid cin as much as you can, it's very inefficient and lead to lots of problems.
The delimiting character is the character that tells the program to stop reading from the input stream when it is found. The default is \n which represents a newline. For example with the following statement
|
getline(std::cin, randomString, '\n');
|
input would continue to be asked of the user until a newline character was found. Basically it means that it would keep reading until the user pressed the Enter or Return key on their computer. If I were to make this statement:
|
getline(std::cin, randomString, '*');
|
Input would continue to be read and stored into randomString even over multiple lines of input until a * was found. This means I can enter multiple lines like this:
Mary had a little lamb
Who's fleece was white
as snow*
And when the * was found in the third line input would stop. In your example of saying
|
getline(std::cin, word1, ' ');
|
This would read from the input stream until a space was found, so it has the opposite effect of what you said, only returning a single word.
Also while you said "Now the getline() uses "cin" in it." this is true, but you can replace it with any other stream. The most common alternative is to read from a file. For example if you opened a filestream called fileStream you could say the following:
|
getline(fileStream, line1, '\n');
|
This would retrieve the first line from the file.