Home > Backend Development > C++ > body text

Usage of cout<
下次还敢
Release: 2024-04-29 09:56:22
Original
392 people have browsed it

In C, cout<

Usage of cout<<endl; in c++

##Usage of cout<

Concept:

cout<

Usage:

Use cout<
cout << data << endl;
Copy after login

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
Copy after login

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<

Related labels:
c++
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!