[EMAIL PROTECTED] wrote:
> -------- Original-Nachricht --------
>> Datum: Thu, 17 Apr 2008 14:16:01 +0100
>> Von: "Paul Herring" <[EMAIL PROTECTED]>
>> An: [email protected]
>> Betreff: Re: [c-prog] endianness questions
> 
>> Any more details on this app in case others know more about it. Sounds
>> like my Solution#2 may be more suitable.
>>
>> -- 
> 
> Sounds like your method 2 would require me to use additional libs ,if i 
> understand right , which seems a bit overkill really, just for this.
> It doesnt seem that difiicult to just swap the bytes manually, if needed. I 
> think i rather go that way instead of depending on libs ..
> Ive just done more tests, and it seems bool values are also stored different 
> ,ie affected by endianness. Which seems strange to me ?
> So in that case , i guess i could just have an int in my fileheader, set that 
> to 5 or whatever, and then use that to determine the endianess of the file on 
> loading by cheking wheter its 5....
> 
> Thanks
> Max

Instead of swapping bytes, you could always use shifting.  Bits in bytes 
are almost always ordered the same way (bit 7 to 0).

char MyInt[sizeof(int)];

for (int x = 0; x < sizeof(int); x++)
{
   MyInt[x] = (char)(YourInt & 0xFF);
   YourInt = YourInt >> 8;
}

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to