DEV Community

Cover image for Keyboard Input

Keyboard Input

blender profile image Saloni Goyal ・Updated on ・1 min read

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!

Discussion (0)

Editor guide