Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!mailrus!ncar!tank!gargoyle!keenan From: keenan@gargoyle.uchicago.edu (Philip Keenan) Newsgroups: comp.lang.c++ Subject: Need help with AT&T CC (C++) on Sun 3/60 - simple question Keywords: AT&T CC C++ Message-ID: <399@gargoyle.uchicago.edu> Date: 7 Jun 89 16:19:50 GMT Distribution: usa Organization: U. Chicago Computer Science Dept. Lines: 45 Hi. I have been using GNU C++ and now want to use the AT&T C++ compiler CC, on a Sun 3/60 under UNIX. Mostly the two versions seem the same, except with streams. In particular, I can't get streams other than the standard ones to work. I think there must be something specific to CC that I am leaving out -- can anyone tell me what I am doing incorrectly? I am enclosing a copy of a very short program based on Stroustrup p. 235, designed to open a file named "outFile" and write a line of text to it. On my system, this compiles fine with CC, but when I run the a.out file, the "outFile" is created but not actually written to, and the stream state becomes "bad", so I get an error message. (The error message, using the predefined ostream "cout", works fine.) Do I have to do something else to get the file opened for output? Here's the program and results: ************************************************************************ /* filetest.c Simple test program for AT&T C++ on gargoyle -- Phil Keenan 6-3-89 */ #include main() { filebuf f1; if(f1.open("outFile",output)==0) { cout << "output error\n"; exit(1); } ostream to(&f1); to << "This is a test.\n"; if(to.bad()) { cout << "error in ostream\n"; exit(1); } } ************************************************************************** : CC filetest.c CC filetest.c: cc filetest..c -lC : a.out error in ostream : ************************************************************************** If anyone can help, I'd greatly appreciate it. For more info contact keenan@gargoyle.uchicago.edu Thanks very much! - Phil Keenan