Get and getline

difference between get and getline ?

string s;
cin.get(s) works like cin>>s. It ignores any spaces in the input string.
But cin.getline() also considers the spaces in the input string.
For example -
Lets say the input string is - “Hello World”
If we have used cin.get(s) and we cout<<s, the output will be “Hello”.
In the other case, the output will be “Hello World”.

i tries it for int it gave me error

It works only for strings.
For integers, us cin>>i only.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.