DEV Community

Cover image for Keyboard Input
Saloni Goyal
Saloni Goyal

Posted on • Edited on

Keyboard Input

So far we have learnt how to use std::cout and print to the screen.

You can store keyboard input into a local variable using cin (pronounced c-in).

int i;
cin >> i;

>> is a two character operator.

The stream I/O library takes care of parsing the input and storing it in the variable.

  • Type rules still apply.

Alt Text

With this we have learnt -

  • How to read from keyboard and write to screen using STL.
  • Variables and Expressions in C++ have types.

Please leave out comments with anything you don't understand or would like for me to improve upon.

Thanks for reading!

Top comments (0)