Re: Wierd newbie problem

From: Jonathan Mcdougall (jonathanmcdougall_at_DELyahoo.ca)
Date: 12/22/04


Date: Tue, 21 Dec 2004 19:14:29 -0500

Old Wolf wrote:
> Sisk wrote:
>
>>cout<<"What is your name?";
>>cin.getline (a,20);
>>cout<<"Oh, hello monkey***. It was monkey***, right?"
>>cin.getline (b,20);
>>cout<<"No no no, your name can't be "<<a<<".
>> It has to be Monkey***. It is, isn't it?";
>>cin.getline (b,20);
>
>
> You should flush cout before reading from cin. I think
> it's possible for the text to not actually display
> if you haven't flushed the stream.

std::cin flushes std::cout automatically (look up std::basic_ios::tie()).

> If you were running this program on a terminal without
> local echo (ie. the input keystrokes don't appear on
> the screen automatically), you would see on the screen:
>
> What is your name?Oh, hello monkey***.

?? That's irrelevant.

> etc. etc.
>
> Example: cout << "What is your name?" << endl
> endl writes a newline and flushes the stream.

Yes, but what's the point?

Jonathan


Loading