Computing.Net > Forums > Programming > C: Read signed 16 bit binary file

C: Read signed 16 bit binary file

Reply to Message Icon

Original Message
Name: Selma
Date: November 24, 2003 at 12:22:09 Pacific
Subject: C: Read signed 16 bit binary file
OS: Window 2000
CPU/Ram: 256
Comment:

Hi,

How to read signed 16-bit binary file?
I opened the file with,
pFile = fopen ("TestRawData","rb");
and I have
fread(&number_bin, 2,1,pFile); to read the data,
but it's not reading the correct value. Does fread only return unsigned values? If so, what command should I use in order to read signed 16-bit?

Thanks! This simple thing has driven me crazy for the passed full day. Please help!

Selma


Report Offensive Message For Removal


Response Number 1
Name: myxp
Date: November 24, 2003 at 16:05:15 Pacific
Reply: (edit)

Selma:

Try to use:

short int number_bin;

If you're still in trouble, let me know - OK?

"fread" returns the number of items read from
the "pFile" stream. If "pFile" points to 10 items, and you decide to read say 4 of these items then the return value is 4.


MYXP


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: C: Read signed 16 bit binary file 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge