Home  >  Article  >  Backend Development  >  Usage of cout<

Usage of cout<
下次还敢
下次还敢Original
2024-04-28 19:30:21422browse

In C, cout<

Usage of cout<<endl; in c++

##Usage of cout<

Concept:

cout<

Usage:

Use cout<
cout << data << endl;

where:

  • cout:Standard output object
  • data:The data to be output can be a string, numerical value, variable or expression
  • endl: Line break

Effect:

When using cout<

  • Output data: Output the value of data to the standard output device.
  • Line break: Wrap the line after the output data.

Example:

#include <iostream>

using namespace std;

int main() {
  cout << "Hello World!" << endl;  // 输出 "Hello World!" 再换行
  cout << 123 << endl;  // 输出数字 123 再换行
  return 0;
}</p>
<p>Output:<strong></strong></p>
<pre class="brush:php;toolbar:false">Hello World!
123

Notes:

    endl is a newline character, and "\n" is also a newline character. They can both be used for line breaks, but endl is recommended because it is more portable.
  • cout<

The above is the detailed content of Usage of cout<

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:How to use cout in c++Next article:How to use cout in c++