How good is YOUR UNIX?

Steven M. Kramer smk at axiom.UUCP
Fri Feb 10 09:51:31 AEST 1984


What will:
	fprintf (file, "string with zero %c in it\n", '\0');

do on YOUR machine (assuming file is properly decared to be FILE * and
a file is opened OK...).
For you slow ones, the point is will the zero byte actually get
printed out?  If not, your doprnt has a bug.  Some doprnt()s know
the character argument is turned into an integer (basic C stuff).
Doprnt reads bytes, checks to see if 0, if so, backs up in the resultant
string and then goes to the next byte for sizeof(int)/sizeof(char)
on your machine.  The bug is that you can't print a '\0'!  ...and yes,
I want to for instance when I want to write strings to a file WITH the
null byte.
-- 
	--steve kramer
	{allegra,genrad,ihnp4,utzoo,philabs,uw-beaver}!linus!axiom!smk	(UUCP)
	linus!axiom!smk at mitre-bedford					(MIL)



More information about the Comp.unix.wizards mailing list