🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1330

C700 streams

#1330
From: vincent
Date: Mon, 07 Sep 1992 15:22
54 lines
1473 bytes

//////////////////////  cut here /////////////////////////////////

#include	<fstream.h>
#include	<iomanip.h>

main (int argc, char **argv)
{
	fstream ci;
	char s [3];

	ci. open (argv [1], ios::in | ios::binary);
	ci. unsetf (ios::skipws);

	s [1] = '_';
	s [2] = '\0';

	while (ci. good ()) {
		ci >> s [0];
		if (ci. eof ())
			break;
		cout << s;
	}
}

//////////////////////  cut here /////////////////////////////////


Looks benign, well it is. BUT I've got a problem with it.

My input file contains "Hello World!"

My output is:

__e_l_l_o _W_o_r_l_d_!_
_


If I remove ios::binary from my open input file it works as expected.

A N Y   I D E A S   ? ? ?

P.S. Of course I played with this piece of code for a while and found
some solutions (i.e. replace the string whith a char) but I would
like to know more about this. I've also used CodeView but it didn't
help me. I know now that the string is correctly passed to the cout
manipulator. And that it affect only the first charater of that string
funy it looks like the second char ('_') is duplicated in the first
position; ?????

             }8-[] 

vincent@datmuc.dat.de
Technical Details
Message-ID: <1263@datmuc.UUCP>
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!usc!snorkelwacker.mit.edu!ira.uka.de!datmuc!vincent

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!usc!snorkelwacker.mit.edu!ira.uka.de!datmuc!vincent
From: vincent@datmuc.UUCP (vincent)
Newsgroups: comp.os.msdos.programmer
Subject: C700 streams
Message-ID: <1263@datmuc.UUCP>
Date: 7 Sep 92 15:22:12 GMT
Lines: 55