Re: Wierd newbie problem
From: Jonathan Mcdougall (jonathanmcdougall_at_DELyahoo.ca)
Date: 12/22/04
- Next message: Jonathan Mcdougall: "Re: pesky Pointers !!"
- Previous message: Chris \( Val \): "Re: pesky Pointers !!"
- In reply to: Old Wolf: "Re: Wierd newbie problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Jonathan Mcdougall: "Re: pesky Pointers !!"
- Previous message: Chris \( Val \): "Re: pesky Pointers !!"
- In reply to: Old Wolf: "Re: Wierd newbie problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]