#include #include "msdefs.h" #include "msport.h" #include "stdlib.h" static void ChFus(pch, val) /* Store long value in character array */ char *pch; /* Pointer to destination */ USHORT val; /* Value to store */ { pch[0] = val; pch[1] = val >> 8; } static void ChFul(pch, val) /* Store long value in character array */ char *pch; /* Pointer to destination */ long val; /* Value to store */ { ChFus(pch, (USHORT)val); ChFus(pch+2, (USHORT)(val >> 16)); } char buf[5]; /* Big enough for a mis-aligned long */ main(argc,argv) int argc; char *argv[]; { int i; ChFul(&buf[1], atol(argv[1])); for (i=0; i<5; i++) { printf(" 0x%02X", buf[i]); } printf("\n"); }