From: Michael Smith Newsgroups: comp.os.msdos.djgpp Subject: Re: stderr | stdout > file Date: Wed, 07 Apr 1999 01:42:25 +0900 Organization: Emmenjay Consulting Lines: 53 Message-ID: <370A3971.7B4E@zip.com.au> References: <3703B753 DOT 6FC4C8DE AT geocities DOT com> NNTP-Posting-Host: 61.8.18.225 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Win95; I; 16bit) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com The Beyonder wrote: > > In DJGPP how can I pipe stderr or stdout to a file like foo.dmp? I > assumed something like: > // code... > stdout = fopen( "foo.dmp", "wt" ); > // code.. > > but DJGPP gives me: > > non-something lvalue.... Do you mean: "invalid lvalue in assignment"? If you want help, it's a good idea to take the extra three seconds to write down the correct error message. Use freopen(). #include #include const char *logname = "foo.dmp"; int main( void ) { char cmd[128]; /* Reassign "stderr" to logname */ if (!freopen( logname, "w", stderr )) { fprintf( stdout, "Error on freopen\n" ); return 1; } fprintf( stderr, "Something for the logfile\n" ); fclose( stderr ); fprintf( stdout, "Finished executing: dumping %s\n", logname ); sprintf( cmd, "type %s", logname ); system( cmd ); return 0; } -- ######################################################################## Michael Smith emmenjay AT zip DOT com DOT au Emmenjay Consulting Pty Ltd http://www.zip.com.au/~emmenjay/ Computers *ARE* user-friendly. You just need to be properly introduced.