1.

Read the following code char str [30]; cin>>str; cout<<str;If we give the input “Green Computing”, we get the output “Green”. Why is it so? How can you correct that?

Answer»

The input statement cin>> cannot read the space. It reads the text up to the space, i.e. the delimiter is space. To read the text up to the enter key gets() or getline() is used.



Discussion

No Comment Found

Related InterviewSolutions