Home > Backend Development > C#.Net Tutorial > c++ output statement

c++ output statement

Release: 2019-10-25 16:17:36
Original
14390 people have browsed it

c++ output statement

The C standard library provides a rich set of input/output functions. C's I/O occurs in streams, which are sequences of bytes. If a stream of bytes flows from memory to a device (such as a display, printer, disk drive, network connection, etc.), this is called an output operation.

Standard output stream (cout)

The predefined object cout is an instance of the iostream class. The cout object "connects" to the standard output device, usually the display screen. cout is used in conjunction with the stream insertion operator << as shown below:

#include <iostream>
 using namespace std; 
int main( ){
   char str[] = "Hello C++"; 
   cout << "Value of str is : " << str << endl;}
Copy after login

When the above code is compiled and executed, it produces the following results:

Value of str is : Hello C++
Copy after login

C Depending on the data type of the variable to be output, the compiler selects the appropriate stream insertion operator to display the value. The << operator is overloaded to output data items of built-in types (integer, float, double, string, and pointer).

Stream insertion operator << can be used multiple times in a statement, as shown in the example above, endl is used to add a newline character at the end of the line.

The above is the detailed content of c++ output statement. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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