954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

binary file

hi all ,
i have a program that read its input from a file in binary mode!
now i nead to store this data and to compare it with another data.
which datataype can my input take.

also, the comapred stream is in this form 0004a4900
i made this stream as a cons int and then with 0x it is already stored as an hex. stream
now when i read i want to search this strream in my input file

ghadahelal
Light Poster
42 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

>which datataype can my input take.
The same data type you used to write it if you want a meaningful comparison. If you're just checking for equality, you can use unsigned char and compare every byte individually.

>also, the comapred stream is in this form 0004a4900
>i made this stream as a cons int and then with 0x it is already stored as an hex. stream
>now when i read i want to search this strream in my input file
There's no question here.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

unsigned char is for byte or what!!
i mean what is the difference between char and unsigned char?

ghadahelal
Light Poster
42 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

>i mean what is the difference between char and unsigned char?
char isn't portable because it could be either signed or unsigned.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

and what does unsigned char mean?

is each byte 'll read as an unsigned char?

ghadahelal
Light Poster
42 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Yes.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You