In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "C++ setw () function how to use", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "C++ setw () function how to use it!"
Setw (int n) is the field width setting used in the output operation in C++. It sets the field width of the output, where n represents the field width. It is only valid for the following output, and then changes back to the default domain width at the end of the subsequent output. When the length of the following output field is less than n, fill in front of the field with a space; when the length of the output field is greater than n, all are output as a whole.
The syntax format of C++ setw () is as follows:
Setw (n)
N stands for width and is represented by numbers.
The setw () function only works on the output that follows.
When the length of the following output field is less than n, fill it with a space in front of the field, and when the length of the output field is greater than n, the whole output is output.
The following example demonstrates the use of the setw () function:
Example
# include # include using namespace std;int main () {/ / begins with a width of 4, and the subsequent runoob character length is greater than 4, so it does not work: cout "runoob", "runoob" return 0;}
The output of the above code is:
Runoobrunoobrunoob runoobrunoobrunoob
Setw () is filled with spaces by default, and can be padded with setfill () to set other characters.
Example # include # include using namespace std;int main () {cout'*') "runoob" return 0;}
The output of the above code is:
* runoob Thank you for your reading. The above is the content of "how to use the setw () function of C++". After the study of this article, I believe you have a deeper understanding of how to use the setw () function of C++. The specific usage still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.