Re: Output of the printf(a,*a,**a) where a is of type int [][][]
CBFalconer <cbfalconer@yahoo.com> writes:
> Keith Thompson wrote:
> ... snip ...
>>
>> Yes, the program exhibits undefined behavior, and yes, that
>> absolutely should be fixed, but that doesn't actually explain
>> the behavior, and there is another explanation. There's
>> nothing wrong with pointing out the undefined behavior *and
>> then* answering the original question.
>
> Undefined behaviour can do _anything_.
True.
> No explanation is needed.
Nonsense. It was obvious from the beginning that the OP was
attempting to print the values of a, *a, **a, and &a, and wanted to
know why they all appeared to have the same value. He clearly did
require an explanation (i.e., he came to us for ), and digging
through the undefined behavior to get to what he was actually asking
about was easy enough that several of us managed to do it.
A C program can behave in arbitrarily obnoxious ways in the presence
of undefined behavior. We don't have to do likewise.
--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|