Hi All,

I am having difficulty finding the right C code to convert a data file. I previously succeeded in converting this format using Python but to improve the speed and portability I now wish to code it in C and that is presenting me with problems.

I have a binary data file which contains numerical data in Sign Magnitude Integer format (obsolete and annoying). Essentially this means there are two bytes of information per record, one determines the sign of the number and the other the magnitude. That is not the problem I am having really though. I do not know the built in ANSI C syntax for converting binary data to ascii format. Once that is done I will need to undo the SMI data and will be left with numbers with base 16 (hex) which I then need to convert to base 10 (decimal).

The information I need is how to convert binary data to ascii data (in small segments of 1 or 2 bytes at a time)...and also if there is a builtin for ansi C which will convert from hex to decimal.

I have been playing with sprintf but I am not sure if this is the way forward - it doesn't seem to be yielding the right answers so far anyway.

Thanks guys!

Arthur.