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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C: Read signed 16 bit binary file

Reply to Message Icon

Name: Selma
Date: November 24, 2003 at 12:22:09 Pacific
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



Sponsored Link
Ads by Google

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

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C: Read signed 16 bit binary file

C : Reading from a file www.computing.net/answers/programming/c-reading-from-a-file/4682.html

C : read/write bit by bit a binary www.computing.net/answers/programming/c-readwrite-bit-by-bit-a-binary/10592.html

array to binary in c++? www.computing.net/answers/programming/array-to-binary-in-c/2981.html