Sujet : Re: The joy of octal
De : OFeem1987 (at) *nospam* teleworm.us (Chris Ahlstrom)
Groupes : comp.os.linux.miscDate : 12. Nov 2024, 13:29:12
Autres entêtes
Organisation : None
Message-ID : <vgvhmp$1j7v5$1@dont-email.me>
References : 1 2 3 4
User-Agent : slrn/1.0.3 (Linux)
Louis Krupp wrote this post while blinking in Morse code:
On 11/11/2024 1:58 PM, Chris Ahlstrom wrote:
John Ames wrote this post while blinking in Morse code:
>
On Sat, 9 Nov 2024 09:36:58 -0500
Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
>
020111 067544 023556 020164 062556 062145 067040 020157 072163 062545
065556 067151 020147 062550 060570 062544 064543 060555 020554 005012
041165 072040 073350 060564 020151 063040 074557 072447 071145 020167
071151 072151 067147 020146 071157 066400 060440 061151 063455 062556
062151 060556 020155 060543 064151 067145 027056 027077
Damn, I still haven't found a program that would easily reverse octal to a
string.
>
>
This is crude, but it seems to work for the post you're replying to,
with big-endian two-byte integers:
>
===
#include <stdio.h>
>
int main(void)
{
union {
unsigned short s;
char c[2];
} w;
unsigned int wi;
char junk;
>
while (scanf("%o%c", &wi, &junk) > 0) {
w.s = wi;
printf("%c%c", w.c[1], w.c[0]);
}
printf("\n");
>
return 0;
}
===
>
To read a sequence of two-byte octal little-endian integers, swap w.c[1]
and w.c[0].
Thanks!
-- After all, what is your hosts' purpose in having a party? Surely not foryou to enjoy yourself; if that were their sole purpose, they'd have simplysent champagne and women over to your place by taxi. -- P. J. O'Rourke