C++ Basics: User Input - std::cin

Поділитися
Вставка
  • Опубліковано 4 жов 2024
  • C++ User Input is done mainly through the cin object.
    We have already learned the usage of cout, and cin is also used in mostly the same way, except the data flow direction is now reversed. And also note that we have to declare a variable before using cin because we need to store the data coming from the user.
    So, just like cout, cin is also an object and the right-shift operator is overloaded in the istream class. And hence, how this works is, when we enter data in the console, that data is passed to the cin object, and then it is passed to the variable next to it. However, when input is taken from the console or standard input stream, inputs are differentiated with spaces (or with characters which is a special case). Hence, if we enter 2 numbers with spaces in between, this program will just grab the first one and output it because the cin identifies them as 2 inputs. This really becomes such an important case when you try to get more sophisticated input using strings with spaces and stuff. So, as the cin differentiates input using white spaces, those words you type, are identified as different inputs. Hence, what you input will not be the output.
    Each and every method to get around these issues and other important tips will be discussed in further detail in this video!
    ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼
    🔴 My Original Rig: 🔴
    ▶Intel i7 9700F : amzn.to/3fBW4RY
    ▶HyperX Fury 16GB 2666MHz DDR4 : amzn.to/2SNTxun
    ▶GIGABYTE GeForce GTX 1650 Windforce OC 4G Graphics Card : ▶amzn.to/2WHfmNq
    ▶WD Blue SN550 1TB NVMe Internal SSD : amzn.to/3fIL6dN
    ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼
    ❌ DO NOT CLICK THIS!!! ----- bit.ly/youtube...
    ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ ⚠️STOP WASTING TIME ON⚠️
    • Channel Management
    • Creating Thumbnails
    • Keyword Research
    • Adding Info Cards
    • Optimizing Videos
    • Managing Comments
    • AND A LOT MORE
    TubeBuddy is here to do all that for you!!
    If you're a content creator like me and would love to speed up your workflow and target promotions, click this link and install the TubeBuddy Extension for FREE!
    www.tubebuddy....
    ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼
    Useful Links
    Blog Post: www.scbr.ml/20...
    ===========================================
    Watch the Previous Video:
    Data Types in C++: • C++ Basics: Data Types
    Also Watch the Entire Playlist: • C++ Basics in Sinhala ...
    ==========================================
    Get Social
    Facebook: (PAGE) / scibersl
    (GROUP) / programmingsrilanka
    Instagram: / scibersl
    ==========================================
    Visit Us : www.cyberweb.ga
    for any useful material including project files and software downloads.
    Download Scorthut : www.cyberweb.ga...
    Make sure to comment down your ideas below!
    OR, you can mail me via,
    mailto:
  • Наука та технологія

КОМЕНТАРІ • 7