Topic: Why doesn't Symantec C++ support cout <<?


Author: pisces@hitel.kol.co.kr
Date: 1995/06/05
Raw View
Tony Ching-Kong Hwang (thwang@primenet.com) wrote:
: It prints out the printf, but not the cout! HELP! I also searched through
: all the on-line help, and could find no references to cout. Isn't cout
: standard C++? thanks

Yes, 'cout' is standard C++, but don't search by 'cout'.
In case of Borland C++, first, I have searched by 'cout' in 'iostream.h',
next, referenced by class name of 'cout'.
'cout' is global object of a class, and both 'cin' and 'cerr' is also.

-- from Taejon, Korea --
-- Pisces, Kim Yunsoo --





Author: Stan Mulder <mulder@csee.usf.edu>
Date: 1995/06/01
Raw View
On 29 May 1995, Tony Ching-Kong Hwang wrote:

> I just bought Symantec 7.0 C++, and I wrote some code with printf, and
> cout <<, like this:
>
>
>  printf("by TH\n");
>  cout << "written by ...";
>
>
> It prints out the printf, but not the cout! HELP! I also searched through
> all the on-line help, and could find no references to cout. Isn't cout
> standard C++? thanks

Tony,

It's generally not a good idea to combine the two methods of io because
they use two different buffering systems, and things seem to go haywire as
you noticed. However, the designers have provided the ios member function
sync_with_stdio() to coordinate the two buffering systems. If you add a
call to this member function you should be able to use printf and cout in
together. It is not recommended however because it slows things down. I
believe the reason for its existence is to allow new code to coexist with
old code. The real solution is to migrate to the newer iostreams.

You can test the following with and without the synchronization to see
how it performs on your system. You might not notice problems displaying
it on the screen, so try redirecting the output to a file and look at the
results.

void test()
{
   //ios::sync_with_stdio();
   for (int i = 0; i < 100; i++)
   {
       printf("test with printf\n");
       cout << "test with cout\n";
   }
}

 -Stan-

-----------------------------------------------------------------------------
  Stan Mulder  --  mulder@csee.usf.edu |
       Information Systems C/C++       |
 University of South Florida, Lakeland |  Acceptance is usually the answer.
-----------------------------------------------------------------------------






Author: mick@omni.voicenet.com (Michael Lester)
Date: 1995/06/02
Raw View
I have similar problem using printf and cout with MSVC20 on NT when I
use the AllocConsole API call.

When I do a call to printf and cout before AllocConsole all works fine
and both commands output to the screen.  After I call AllocConsole
only printf continues to work.

What I have done to make this work is add the code.....

filebuf fpStdOut(1);   // file buffer to stdout
cout = &fpStdOut;  // Make cout point to stdout as it should

only then will cout work, but I am not really happy with this
solution.  Does anyone know of a better method of fixing this problem?


Mick








Author: thwang@primenet.com (Tony Ching-Kong Hwang)
Date: 1995/05/29
Raw View
I just bought Symantec 7.0 C++, and I wrote some code with printf, and
cout <<, like this:


 printf("by TH\n");
 cout << "written by ...";


It prints out the printf, but not the cout! HELP! I also searched through
all the on-line help, and could find no references to cout. Isn't cout
standard C++? thanks


     - Tony

P.S. sorry about below, but primenet's return keys doesn't seem to work,
really REALY annoying. --
-------------------------------------------------------------------------------

cout << "written by Tony
Hwang\n";
Athwang
__  __     ____  ___       ___ ____

thwang@primenet.com                      /__)/__) / / / / /_  /\  / /_    /
                                        /   / \  / / / / /__ /  \/ /___  /-------------------------------------------------------------------------------





Author: zwets@midas.rivm.nl (Marco van Zwetselaar)
Date: 1995/05/29
Raw View
Tony Ching-Kong Hwang writes:

 > I just bought Symantec 7.0 C++, and I wrote some code with printf, and
 > cout <<, like this:
 >
 >  printf("by TH\n");
 >  cout << "written by ...";
 >
 > It prints out the printf, but not the cout! HELP!

It's not in the printf or cout! It's in the strings! Try this:

 cout << "by TH\n";
 printf("written by ...");

then think.

Marco