DEV Community

Cover image for Keyboard Input
Saloni Goyal
Saloni Goyal

Posted on • Edited on

1 1

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!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay