In <sl************ *******@ekoi.cl .cam.ac.uk> Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Minti wrote: Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> wrote in message news:<bn******* *****@ID-114079.news.uni-berlin.de>... Minti wrote:
> Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> wrote in message news:<bn******* *****@ID-114079.news.uni-berlin.de>...
>> sugaray wrote:
>> > does the expression int a=printf("%d\n" ,a); implementation dependent ?
>>
>> No, it's undefined, since `a' hasn't been initialized at the time you
>> pass its value to printf(). Don't do that.
>
> By undefined do you mean undefined "value" or undefined "behaviour" ?
In this case there is no difference. The value of `a' is
indeterminate, so the behaviour when it is used is undefined.
But given the 'declaration'
int a = printf("%d", a);
Does the standard gaurantee that "a" would have been 'defined' before
its value is used by the printf.
Yes. The scope of `a' begins at the end of its declarator.
So, the answer is actually "no": if `a' was already defined prior to our
definition, the `a' in the printf call refers to the "new" `a', currently
uninitialised and not to the "old" `a'.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
Da*****@ifh.de