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/03 Report--
This article mainly shows you "how to use cin in C++". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn how to use cin in C++.
Preface
In C++, cin is generally used to interact with each other to obtain user input information. Cin is the standard input stream object in C++ programming language, that is, the object of stream class. Cin is mainly used to read data from standard input, which refers to the keyboard of the terminal. Cin > >, cin.get () and cin.getline () are mainly used. When cin reads data, it also obtains data from the buffer. When the buffer is empty, the member function of cin will block waiting for the data to arrive. Once there is data in the buffer, it will trigger the member function of cin to read the data.
1. Cin1, cin > >
Continuous reading is supported, with Tab and space as delimiters and newline characters as closing symbols
/ *-> File Name: cinDemo01.cpp > Author: Jxiepc > Mail: Jxiepc > Created Time: Mon 20 Sep 2021 10:09:55 AM CST- -- * / # include#include#includeint main (int argc Char * argv []) {std::string s While (std::cin > > s) {when std::cout reads data from the cache, it automatically ignores Tab, Space, and line feeds that exist as the first character, continues to read the next character, and waits if the cache is empty. However, if the read is successful, the delimiter after the character is left in the buffer and cin > > is not processed.
2. Cin.get ()
Read characters, including spaces
/ *-> File Name: cinGetDemo.cpp > Author: Jxiepc > Mail: Jxiepc > Created Time: Mon 20 Sep 2021 10:20:59 AM CST- -* / # include#include#include#includevoid test02 () {char str [256] Std::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.
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.