Hipo wrote:[color=blue]
>
boaz_sade@yahoo.com schrieb:
>[color=green]
>> Greg wrote:
>>[color=darkred]
>>> Rolf Magnus wrote:
>>>
>>>> Hipo wrote:
>>>>
>>>>> Hi.
>>>>>
>>>>> I have the following code:
>>>>>
>>>>> unsigned char temporary[160];
>>>>> unsigned __int64 *reader = (unsigned __int64*)&temporary+20;
>>>>
>>>> &temporary is the address of the array. &temporary+20 would be the
>>>> address
>>>> of the 20th element of an array of arrays of 160 char. You probably
>>>> meant
>>>> temporary+20 (without the &).
>>>
>>> Eliminating the & in front of the temporary array makes no difference -
>>> the address of the reader variable is the same. And that address works
>>> out to the 21st element of an array of 8 byte integers which in turn is
>>> equivalent to the address of the 161st character of the 160 character
>>> array. In other words, the reader variable starts by pointing to the
>>> first byte beyond the memory allocated for the temporary array.
>>>
>>> This code certainly makes a good example why pointers and C arrays are
>>> best avoided.
>>>
>>> Greg[/color]
>>
>> I think that this is an example of how you can violatate and rule about
>> writing good code.[/color]
>
>
> Define good code. I need the data that way and therefor work on it that
> way.
>[color=green]
>> Above all this is not even deterministic on different compilers.[/color]
>
>
> Not desired. One specific compiler on one specific platform.
>[color=green]
>> Even better it seems that the write of this code don't know how should
>> it really works.[/color]
>
>
> Believe me, I do.
>[color=green]
>> Last and not least why on earth would you ever even think about writing[/color]
>[color=green]
> > this kind of code?[/color]
>
> It's the most efficient way of using data in the algorithm I write.
>
> g, hipo[/color]
Are you sure it's the most efficient way of using data? Have you measured?
Joe