| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [--- Ebcdic ---] |
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)SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.