home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
- From: jss@lucid.com (Jerry Schwarz)
- Subject: Re: <stdio.h> and <iostream.h>
- Message-ID: <1992Sep2.180230.1427@lucid.com>
- Sender: usenet@lucid.com
- Reply-To: jss@lucid.com (Jerry Schwarz)
- Organization: Lucid, Inc.
- References: <1SEP199214472267@cnsvax.uwec.edu>
- Date: Wed, 2 Sep 92 18:02:30 GMT
- Lines: 36
-
- In article <1SEP199214472267@cnsvax.uwec.edu>, tannerrj@cnsvax.uwec.edu (Power = 486 + HST Dual Standard) writes:
- |> I am trying to put a text windowing environment on a C++ program
- |> that I have created. The text windowing environment is DFLAT from
- |> DDJ magazine. The problem is DFLAT is ANSI C using stdio.h and
- |> my program is a C++ program with iostream.h. I have read that there
- |> are potential dangers in mixing the two. Any suggestions? Thanks.
- |>
-
- The problems with mixing stdio and iostream is one of syncronization.
- That is since stdio and iostream are each doing their own buffering
- it is possible that
-
- printf("stdio ") ;
- cout << "iostream " ;
-
- would end up with output
-
- iostream stdio
-
- If you can arrange for flush to be called at appropriate points
- there is never any problem. Some implementations
- of stdio will automatically flush when a newline is printed
- to certain output devices (this is called line buffering), and the
- endl iostream manipulator also flushes.
-
- Alternatively you can call ios::sync_with_stdio before you do
- any other iostream operations. This will cause cout and cerr
- to be connected to stdout and stderr which will allow for
- (almost) arbitrary mixing.
-
- There is never any problem when stdio and iostreams are
- being used on different files.
-
- -- Jerry Schwarz
-
-
-