Syntax

C++ Read Input Syntax

In C++, read input: reads from standard input — std::cin >> n;

Quick Answer

Syntax
std::cin >> n;
C++Syntax

Read Input

Code example
std::cin >> n;

Reads from standard input.

Learn More

How to read input in C++

  1. Open your C++ file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C++ Read Input Syntax

Use std::cin >> n;.

Related Syntax References

Frequently asked questions

What is the C++ syntax for read input?

Use this pattern: std::cin >> n;

Can I copy this C++ code example?

Yes. Use Copy code and adapt the example to your program.

Is this C++ syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify