Newsgroups: comp.std.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!ficc!peter
From: peter@ficc.ferranti.com (Peter da Silva)
Subject: Re: scanf %x allows leading 0x?!?
Message-ID: <=2ABSB4@xds13.ferranti.com>
Reply-To: peter@ficc.ferranti.com (Peter da Silva)
Organization: Xenix Support, FICC
References: <161@thor.sdrc.com> <725@taumet.com>
Date: Mon, 13 May 91 23:16:09 GMT

In article <725@taumet.com> steve@taumet.com (Stephen Clamage) writes:
> scjones@thor.sdrc.com (Larry Jones) writes:
> |I was just surprised to discover that the %x conversion specifier
> |used in the *scanf functions allows the target string to have a
> |leading 0x or 0X.

> It is the explicitly-specified behavior in ANSI C.  On systems which
> do not follow the ANSI standard, you may get different behavior.

OK, whose bright idea was this? I know scanf is pretty much a loss in general,
but doesn't this further dilute its reliability?

Given:
	scanf("%x%c", &integer, &byte);

With the input
	4300ay
	0 b
	0cx
	0x

Is this supposed to fail on the final example, or succeed?
-- 
Peter da Silva; Ferranti International Controls Corporation; +1 713 274 5180;
Sugar Land, TX  77487-5012;         `-_-' "Have you hugged your wolf, today?"
