I have a problem, the code is easy kompliiruetsya in exe, and the first two inputs work perfectly, but when it comes time for the third variable program starts to not work with the code all odinkaovo
https://www.onlinegdb.com/online_c++_compiler – you can then quickly skompliirovat.
# include & lt; iostream & gt;
INT MAIN ()
{
STD :: COUT & LT; & LT; "Enter a:"; // ask the user to enter any number
int a = 0;
std :: cin & gt; & gt; a; // get the number of the user and store it in a variable
STD :: COUT & LT; & LT; "Enter b:"; // ask the user to enter any number
char b = 0;
std :: cin & gt; & gt; b; // get the number of the user and stores it in the variable b
STD :: COUT & LT; & LT; "Enter c:"; // ask the user to enter any number
int c = 0;
std :: cin & gt; & gt; c; // get the number of the user and store it in a variable
STD :: COUT & LT; & LT; "Finish" & lt; & lt; STD :: ENDL;
Return 0;
}
The first two variables are correct this is what happens on the
third
Please tell me how to do so that I can introduce a third variable I have this c. If you have any questions to ask.
[23.03.2020 19:22]
Corrected: Changed the names of variables, for greater ease and understanding.
Answer 1, Authority 100%
Well, what do you want?
char dll = 0;
std :: cin & gt; & gt; dll;
Once a char
read – Reads one character (you are not surprised concluded D
in the picture?). But everything else – LL.dll
– comes from the buffer when reading
std :: cin & gt; & gt; lvls;
It is understood that this is not a number – that’s actually in the lvls
nothing to read, to cin
is set error flag fail
(you do not check …).
It’s simple.
Read the line – in line:)