vaks
asked on
simple: read C(++) int and double from file
A simple question:
Some C(++) program has written a lot of ints an doubles to a file. (I know the order of these.) I have to read them in perl (to integers and float point numbers).
Help me with some code.
Ints are 4 bytes, doubles 8.
File byte order: most significant byte first.
I could find it out my self, but have don't have the time right now.
Regards
/Vaks
Some C(++) program has written a lot of ints an doubles to a file. (I know the order of these.) I have to read them in perl (to integers and float point numbers).
Help me with some code.
Ints are 4 bytes, doubles 8.
File byte order: most significant byte first.
I could find it out my self, but have don't have the time right now.
Regards
/Vaks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
For those interested, one reads doubles with:
read (FILE, $buffer, 8);
$buffer = reverse($buffer);
$double = unpack('d',$buffer);
/Vaks