Home  >  Article  >  Backend Development  >  What does cin >> mean in c++

What does cin >> mean in c++

下次还敢
下次还敢Original
2024-04-26 16:09:11860browse

cin >> is an input stream operator in C that reads space-delimited data from standard input and stores them in a specified variable. When used, the operator reads the next token in the input stream and writes the data to variables such as var1 and var2, using spaces as delimiters.

What does cin >> mean in c++

What is cin >>?

In C, cin >> is an input stream operator used to read data from standard input (usually the keyboard). It reads data from the input stream into the specified variable.

Operation method

cin >> The operator reads the next space-separated token in the input stream. If there is no more data in the input stream, it returns false; otherwise, it returns true.

Grammar

cin >> The syntax is as follows:

cin >> var1 >> var2 >> ...;

Among them:

  • var1, var2, etc. are variables used to store input data.

Example

int age;
string name;

cin >> age >> name;

In this example, cin >> will read two values ​​from standard input: One value is stored in the variable age and the second value is stored in the variable name.

The above is the detailed content of What does cin >> mean in c++. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:In c++?:How to useNext article:In c++?:How to use