以下にACプログラムがあります。32ビットメッセージを特定の順序で送信したいと思います(例:0x00000001)。
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <stdint.h>
struct test
{
uint16_t a;
uint16_t b;
};
int main(int argc, char const *argv[])
{
char buf[4];
struct test* ptr=(struct test*)buf;
ptr->a=0x0000;
ptr->b=0x0001;
printf("%x %x\n",buf[0],buf[1]); //output is 0 0
printf("%x %x\n",buf[2],buf[3]); //output is 1 0
return 0;
}
次に、char配列の値を出力してテストします。上記のコメントで出力を得ました。出力は00と01であるべきではありませんか?but [3]が最後のバイトなので?見逃したことはありますか?
ありがとう!