Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: Conversions/casts one more time
Message-ID: <4726@mimsy.UUCP>
Date: Sat, 13-Dec-86 10:35:08 EST
Article-I.D.: mimsy.4726
Posted: Sat Dec 13 10:35:08 1986
Date-Received: Mon, 15-Dec-86 23:54:54 EST
References: <176@unisoft.UUCP> <820@mtund.UUCP>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 28

>> 	printf("\tc = %x, (char)uc = %x, (char)ucf() = %x\n",
>> 	  c, (char)uc, (char)ucf());

In article <820@mtund.UUCP> adam@mtund.UUCP (Adam V. Reed) writes:
>Ugh. %x expects an int, so the result of feeding it a char is,
>*and ought to be*, UNDEFINED.

printf is also a function, so it is not possible to hand it a char.
`char' exists only as a data type (lvalue), not as an expression
type (rvalue), so `printf("%x", (char)c);' sends printf (int)(char)c,
not (char)c.

As to the original question, a cast is (supposed to be) equivalent
to an assignment to a temporary variable of the given type.  The
printf() call above is therefore (supposed to be) equivalent to

	char t1, t2;

	t1 = uc;
	t2 = ucf();
	printf("\tc = %x, (char)uc = %x, (char)ucf() = %x\n",
		c, t1, t2);

Whether this sign extends 0xaa is machine, and sometimes compiler,
dependent.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu