Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use C++ input and output streams cout and cin

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "C++ input and output stream cout and cin how to use", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the C++ input and output stream cout and cin.

1. Important C++ stream classes and stream objects

C++ stream classes commonly used in the std namespace

Cout standard output stream

Cin standard input stream

Standard output stream used by cerr to display errors

Fstream is used to manipulate the input and output streams of files, inheriting ofstream and ifstream

The output stream class used by ofstream to manipulate files, that is, to create files

The input stream class used by ifstream to manipulate files, that is, to read files

Stringstream is used for input and output stream classes of strings, inherits istringstream and ostringstream, and is usually used to convert between strings and other types

Control characters commonly used for flows in std namespaces

Endl inserts a newline character

Ends inserts an empty character

Dec allows the stream to be decimal input or output

Hex hexadecimal

Oct octal

Fixed displays data in fixed-point representation

Scientific displays data in scientific representation

Setprecision sets decimal precision

Setw sets the field width

Setfill sets padding characters

Common usage of 2.cout

Use cout and control characters to display integers in decimal, hexadecimal, and octal formats:

# include # include using namespace std;int main () {coutInput; cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report