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 analyze the IO flow of C++ system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shows you how to analyze the IO stream of C++ system. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Foreword:

This time, I will explain a small knowledge point, which is also the most common knowledge point: no matter what program iostream; writes, it is bound to use IO stream interaction to understand simple IO stream in detail.

1. Iostream standard library

Definition: the IO interface provided by the standard library for interacting with users

Input stream: cin

Output stream: cout, cerr, clog

One of the differences among the output streams:

1. First of all, there are different output targets. Cerr is mainly used to output error information, and clog is mainly used to output log information.

2. The biggest difference in cerr is that the buffer is flushed immediately, and the output is faster. The other two kinds of output information may be lost when the program crashes.

There are other methods for buffer flushing: std::flush, std::endl

2 、 namespace

Mainly to avoid name conflicts, you can see the following code:

Namespace People1 {void fun () {}} namespace People2 {void fun () {}}

There are two functions with the same name in the above code, and the compilation can be passed, which is what the namespace is for.

When using the function fun (), you need to specify a namespace

There are three ways to use namespaces:

/ / 1, domain parser:: People1::fun (); / / 2, using statement using namespace People1;fun (); / / 3, namespace alias namespace ns1 = People1;ns1::fun ()

Note: std is the namespace of the standard library, and it is also the most commonly used one.

3. The difference between C and C++ output

Printf: intuitive to use, but easy to make mistakes

Cout: not easy to make mistakes, but long to write

Clippers 20 formatting library: a new solution (not commonly used at present)

The above content is how to analyze the IO flow of C++ system. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report