top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Difference between cin, cin.get(), cin.getline() in C++?

+1 vote
322 views
Difference between cin, cin.get(), cin.getline() in C++?
posted Jun 2, 2016 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
There are an equivalent number of advantages and drawbacks, and -essentially- all depends on what you are reading: get() leaves the delimiter in the queue thus letting you able to consider it as part of the next input. getline() discards it, so the next input will be just after it.

If you are talking about the newline character from a console input,it makes perfectly sense to discard it, but if we consider an input from a file, you can use as "delimiter" the beginning of the next field.

...