Hi there-
Does anyone have any clue as to what may be causing this problem. I am
trying to read from a binary data value that has temperature values stored in it
in short integer format. So basically, for every 2 bytes of binary data, that value
in short integer is the temperature value. I have written a simple C program to read
in the values from the out.bin binary data file I have, and echo them back to the
console:
It prints out the correct values, here is the C program that I used:
#include<stdio.h>
void main(void)
{
FILE *fin;
short buffer[1];
int num_read;
fin = fopen("out.bin","r");
num_read=1;
while(num_read>0) {
num_read = fread(buffer, sizeof(short), 1, fin);
printf("%d,",buffer[0]);
}
fclose(fin);
return(1);
}
I am trying to write a php file to do the exact same thing, except instead of printing
out the values, I'm going to store them in an array. Anyways, the php script I've
written
looks like this:
<?php
$fp = fopen("out.bin","rb");
$str = fread($fp,2);
while($str)
{
$str = (int)$str;
printf("%d,",$str);
$str = fread($fp,2);
}
?>
The output I get from the php script is complete garble(a whole bunch of 0's, some
1's, some random
int values, etc. I know that PHP doesn't exactly have a short int type, i know that
their integers are actually stored in the C LONG_INT type, which are 8 byte integers.
Do
you think that this may be affecting my script, and if it is, does anyone know of any
workarounds? Your help would be greatly appreciated.
Thanks in advance.
-------------------------------------------------------
Chris Mattmann
Science Data Management and Archiving
[EMAIL PROTECTED]
NASA-JPL Pasadena, CA 91109-8099
Office: 300-324C
Phone: 818-354-8810