• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)


  • Subject: Re: (no subject)
  • From: Chris Gehlker <email@hidden>
  • Date: Tue, 28 Aug 2001 21:08:09 -0700

On 8/28/01 8:04 PM, "Tony Cate" <email@hidden> wrote:

> I know this belongs on the project builder list, but I don't happen
> to know the address and I need a quick answer.
>
> When trying to run a c++ app with the cin object, using the PB IDE,
> output is held up until all the input has occurred. Example:
> #include <iostream>
>
> int main (int argc, const char * argv[])
> {
> float x;
> cout << "Hello, World!";
> cin >> x;
>
>
> return 0;
> }
>
> The text "Hello World" will only print once I've input 'x'. If I had
> 6 cin's, I'd have to put then all in before the output would happen.
>
> 1 Why?

Because that's how it's supposed to work. The Wintel IDE is non-standard.

(Well that's a little strong. The standard doesn't forbid a flush. Lets just
say that C++ isn't supposed to make assumptions about what devices are
attached to standard input and standard output.)

> 2 How do I get around it? (I'm in a c++ class and this is the IDE I'm
> using - everyone else is on wintel stuff.)

Use std::endl or std::flush, depending on whether or not you want a carriage
return. That is:

cout << "Hello World" << endl; // Is better form and works everywhere.
--
C++: The power, elegance and simplicity of a hand grenade.


References: 
 >(no subject) (From: Tony Cate <email@hidden>)

  • Prev by Date: Re: Required in .h
  • Next by Date: Re: Another Cocoa Bug!! :<
  • Previous by thread: (no subject)
  • Next by thread: Re: (no subject)
  • Index(es):
    • Date
    • Thread