Index: [thread] [date] [subject] [author]
  From: Tim Bain <tpb2@duke.edu>
  To  : 
  Date: Sun, 14 Feb 1999 17:04:06 -0500

Re: Outputting to a file

On Sun, 14 Feb 1999, Carl Robert Knerr wrote:

> Date: Sun, 14 FEB 1999 14:44:59 -0500 
> From: Carl Robert Knerr <crk5@duke.edu>
> Newgroups: duke.cs.cps108
> Subject: Outputting to a file 
> 
> We are declaring a ofstream called output which is set to our filename 
> using "output.open(filename.c_str())".  But how do we actually write to the 
> file?  We tried using "output << "blah blah" << "\n";  But nothing is 
> being written to the file.  Suggestions?  Thanks.
 
The only thing that comes to mind is, are you closing
the file when you're done with it?  That might be causing
the problem (maybe...).  One other thing, using endl
instead of "\n" might be something you should be doing;
endl flushes the output buffer, causing everything currently
in the buffer to be written to the file.  I don't know for
sure if "\n" will do this with the << operator...  It
might, but it also might not, and if it doesn't, that
could be a reason why you're never seeing anything.

Good luck.

Tim


Index: [thread] [date] [subject] [author]