Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!mcdougal From: mcdougal@gargoyle.UChicago.EDU (Thomas F. McDougal) Newsgroups: comp.lang.c++ Subject: bug in cout << ? Message-ID: <807@gargoyle.UChicago.EDU> Date: Wed, 18-Nov-87 10:13:13 EST Article-I.D.: gargoyle.807 Posted: Wed Nov 18 10:13:13 1987 Date-Received: Sat, 21-Nov-87 04:47:33 EST Reply-To: mcdougal@gargoyle.uchicago.edu.UUCP (Thomas F. McDougal) Distribution: na Organization: U of Chicago - Computer Science Lines: 50 I hope someone can help me with this. We have no C++ wizards around here yet, and so I have to hope that someone out there will take the time to look this over. I have overloaded the << operator for a particular class; the overloaded version works fine, but now I am getting very strange behavior from cout << while trying to print ordinary character strings. It ignores text and "\n" characters, and prints everything after the first four characters at the beginning of the string. The offending code: cout << "Done doing something...\n"; char* w; while (cin >> w) { ... cout << "Could not find: " cout << w; cout << "\n"; } Instead of: I get: Done doing something... Done doing something... Could not find: abotted tedabotted Could not find: atmo atmo Could not find: disciple ipledisciplenextwordnextwordne... [etc...] Note that it works fine until I enter the loop. Note also that after printing a few words, scrambled and without the "could not find" but at least on different lines, cout gives up altogether and just strings the scrambled words onto one line. No calls are made to the overloaded version of <<. Input is piped from a file on the command line, like this: a.out < inputfile Thanks for your time, folks. --Tom McDougal ARPA: mcdougal@gargoyle.Uchicago.edu UUCP: ihnp4!gargoyle!mcdougal -- --Tom McDougal ARPA: mcdougal@gargoyle.UChicago.edu UUCP: ...ihnp4!gargoyle!mcdougal