0
What is the significance of this code?
#include<iostream> #include<conio.h> using namespace std; int main() { char c; cin.get(c); while(c!='\n') { cout<<c; cin.get(c); } }
1 ответ
0
I sort of un understood what is going on here. My fault was I was entering only one input. Try inputting a sentence. When you input a sentence, here is what happens.
"cin" function assigns the first character of the sentence to c. And the program enters the loop.
In the loop, the cout function outputs the character that was stored in c. And then again in another statement, the cin is taking another character of the sentence, and it again printed until the sentence is broken by ENTER (\n).
In my opinion, I think when we input the sentence, the letters are stored in stream and they are available for cin to input character by character and for cout to output character by character.
Well, this is what I understood. Correct me if I am wrong.