Difference between getlines

I wanted to know the difference between input, can some one explain the difference between cin.getline(); getline(cin, keyword); and cin >> keyword; and any other input i may have missed can you also give an example if you can. The diffrence i know is getline reads the input until a whitespaces is found. Thank you in advance to everyone that helped.
The biggest difference between getline(std::istream&, std::string&) and istream& getline(char*, size_t ) is the type of "string" the first method retrieves a std::string the second method retrieves a C-string. These functions retrieve the strings until the delimiter is encountered. The delimiter is retrieved and discarded. The second method will stop processing the string when either the number of characters match the second parameter or the delimiter is found, whichever occurs first.


The extraction operator>> will retrieve a string (either a std::string or a C-string) stopping when a whitespace character is encountered. Note you should limit the number of characters the extraction operator will try to retrieve by using the proper setw() call prior to the extraction.

By the way did you even try to find and read any documentation for these standard functions?

Topic archived. No new replies allowed.