mardi 20 mars 2018

how is cin and cout working in the below program?

the below program

#include <iostream>
using namespace std;

int main()
{
    char ch;
    while (cin >> ch){
        cout << ch; 
    }
   return 0;
}

input : abcEnter
output : abc

Whatever I type on the keyboard gets printed only when I press Enter i.e. new line.

Why is not each character being printed simultaneously? Which statement here takes the newline as an input and prints all the characters printed till now?

Aucun commentaire:

Enregistrer un commentaire