Subj : [--- Ebcdic ---] To : Neil Heller From : Jasen Betts Date : Mon Nov 10 2003 06:17 am Hi Neil. 08-Nov-03 13:14:00, Neil Heller wrote to Jasen Betts NH>> To make things more interesting, integer values were little NH>> endian but were only 12 bits long. The 13th bit was the start of NH>> the next number. That way every 3 bytes held 2 integer values. JB>> use sscanf() instead of atoi() - you can specifiy field JB>> widths.... NH> Hmmm... if I received a byte value (ASCII) 65 ('A') how would I NH> use sscanf() to specify that val_1 = 6 and val_2 = 5? I've never NH> seen that done with sscanf(). Could you also do do that sprintf()? you need to convert to hex first (I thought that was obvious from the context, sorry.) char buffer[20]; int received='A',val_2,val_2; sprintf( buffer, "%02x", received); sscansf( buffer, "%1d%1d", &val_1,&val_2); it's slightly more impressive with longer inputs. char buffer[20]; Long received=0x747323; int val_1,val_2; sprintf( buffer, "%06x", received); sscansf( buffer, "%3d%3d", &val_1,&val_2); -=> Bye <=- --- * Origin: One less than the checksum of "Jasen Betts" (3:640/1042) .