Another que: Why the data showed in UltraEdit such as " 06 00 5b c6" is showed "06 00 ffffff5b ffffffc6" when using printf and %x ?
This looks like sign extension to me. When you have a negative value store in a variable in 2s compliment format ( which is what most computers use) the top bit is effectively the sign bit, set for negative numbers clear for positive numbers.
If you convert a signed integer type to another signed integer type with more precision, say signed char to signed int (taking ints as 4 bytes for this example) then if you just copied the bits from one type to the other the following would happen.
signed char sc = -1; // bit pattern 0xFF
copying to a signed int without sign extension would result in the bit pattern 0x000000FF or the value 255, not the desired result. Sign extension involves copying the value to the top bit of the lower precision value to all the upper bits of higher precision value so since the top bit of 0xFF is 1 the value 1 is copied to all the higher bits of the unsigned int resulting in the value 0xFFFFFFFF or the value -1.
This doesn't happen for unsigned variables as there is no sign bit, all the bits are value bits. However if you have values that should be unsigned but are held in signed variables if you convert them to a higher precision value you get unwanted signed extension.
When you call printf with its varidac function prototype the compiler does not know how to put the variables onto the stack for passing to the function. In this case all integer type variables with a lower precision than an int are automatically converted to int before they are placed on the stack.
I am guessing that you read the data from your file into a char (which is probably signed by default), then when you pass it to printf it automatically gets converted to an int resulting in unwanted sign extension.
You should either read the data in unsigned char if the data really is unsigned or you can fudge the printf call by casting the data to an unsigned char or unsigned int explicitly which will prevent the signed extension.