From: weiku AT solid DOT ssd DOT ornl DOT gov (Ku Wei) Subject: Re: re-configuring standard input to binary mode 7 Jul 1997 17:34:31 -0700 Sender: mail AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: Original-To: Peter Lu Original-cc: gnu-win32 AT cygnus DOT com In-Reply-To: <33C10D80.53EF@world.std.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Original-Sender: owner-gnu-win32 AT cygnus DOT com It seems to me that the consle input and output are set binary since the following code segment is working fine on my home PC under bash 2.01. However, it will not working properly under DOS prompt in which the '\x0d' is missing due to the property of text mode. PS: I use Sergey's patch of gnuwin32.dll, gnuwin32.a, and bash 2.01 with binary mounting. int main(int argc, char* argv[]) { if( argc == 1) { // ... // need to set cout as binary to make this work under DOS ! // OK with UNIX dos2ux( cout, cin); } else if( argc == 3) { ifstream file_in; ofstream file_out; ... file_in.open( argv[1], ios::in | ios::binary); file_out.open( argv[2], ios::out | ios::binary); ... dos2ux( file_out, file_in); } void dos2ux( ostream & out, istream & in) { char c; while( ( c = in.get()) != -1) if( c != '\x0d') out << c; } Hope this help. Sincerely, Wei Ku *************************************** Department of Physics and Astronomy The University of Tennessee 1408 Circle Drive Knoxville, Tennessee 37996-1200 weiku AT utkux DOT utcc DOT utk DOT edu --------------------------------------- Solid State Division Oak Ridge National Laboratory P.O.Box 2008 Oak Ridge, TN 37831-6032 Phone: (423) 574-5795 Fax: (423) 574-4143 weiku AT solid DOT ssd DOT ornl DOT gov *************************************** On Mon, 7 Jul 1997, Peter Lu wrote: > Hi, > > How does one configure the standard input stream (fd = 0) to run in > binary mode? The default mode seems to be text mode. > > I've tried to use fcntl() to no avail. I've also tried tricks > like dup() and fdopen(). > > Thanks for any help. > > Peter Lu (swift AT world DOT std DOT com) > - > For help on using this list (especially unsubscribing), send a message to > "gnu-win32-request AT cygnus DOT com" with one line of text: "help". > - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".