On 12.10.2006 18:10, Kalman Noel wrote:
> Tim Pease:
>> On 10/12/06, Rolando Abarca <funkaster / gmail.com> wrote:
>>> int b;
>>> read(f, &b, sizeof(int));
>> class IO
>>   def geti( endian = :little )
>>     str = self.read( 4 )
>>     str = str.reverse if endian == :little
>>     str.unpack( 'N' )[0]
>>   end
>> end
> 
> Yet you cannot be sure that sizeof(int) is 4.
> 
> Kalman

class IO
  def geti( endian = :little )
    str = read( [0].pack('N').length )
    str.reverse! if endian == :little
    str.unpack( 'N' )[0]
  end
end

Regards

	robert