> For the complete documentation index, see [llms.txt](https://mr-poston-1.gitbook.io/c++/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mr-poston-1.gitbook.io/c++/1.-c++-basics/1.1-input-output-and-program-structure/1.1.4-getline-and-cin.md).

# 1.1.4 getline and cin

When using `cin`, only the next token is read in. So if you enter a number or word, then press the enter or return key, just the number or word is read in. `cin` leaves the carriage return/enter part of the line.

When using `getline`, everything up to the next carriage return/enter is read.

The issue is that if you use a `cin` and leave only the carriage return/enter, then use a `getline`, you will pick up just that carriage return/enter and nothing more.

To get around this, you need to clear the remainder of the input line after a `cin` before you call the `getline`.

You can do this using the `cin.ignore()` command.

This will clear the remainder of the line and allow the `getline` command to wait for the next line.

Try the example with and without the `cin.ignore()` command to notice the issue.

{% embed url="<https://onlinegdb.com/mLNMsibzH>" %}
getline and cin
{% endembed %}
