what im trying to do is, read from a file, and if its a dog or a cat, then it'll print out to the error stream.
and if its any other animal then it'll print out to standard output (cout)

any help why this code wont work?

07-31-2004

Salem

Didn't we just do this in another thread?

07-31-2004

jlou

Your variable str is a string, but then you try to assign the cerr stream to it. That won't work. Normally, you might have a variable and assign cout or cerr to it as appropriate. In this case, that variable would have to be a reference to ostream, so it is a little more sloppy because you cannot assign to a reference, only initialize it with something. I would suggest something like this: