目的や構造体メンバのデータ型にもよりますが、offsetofか共用体あたりが使えるのではないでしょうか?
offsetoff
C
1#include <stdio.h>
2#include <stddef.h>
3typedef unsigned int uint32_t;
4
5typedef struct{
6 uint32_t a;
7 uint32_t b;
8 uint32_t c;
9}hoge_m;
10
11int main()
12{
13 uint32_t out;
14 char* hoge_pnt;
15 hoge_m hoge_bff = {1,2,3};
16
17 hoge_pnt = (char *)&hoge_bff+offsetof(hoge_m, a);
18 out = *(uint32_t*)hoge_pnt; //aを取り出す
19 printf("%d\n", out);
20 hoge_pnt += offsetof(hoge_m, b)-offsetof(hoge_m, a);
21 out = *(uint32_t*)hoge_pnt; //bを取り出す
22 printf("%d\n", out);
23 hoge_pnt += offsetof(hoge_m, c)-offsetof(hoge_m, b);
24 out = *(uint32_t*)hoge_pnt; //cを取り出す
25 printf("%d\n", out);
26
27 return 0;
28}
共用体
C
1#include <stdio.h>
2#include <stddef.h>
3typedef unsigned int uint32_t;
4
5typedef union {
6 struct{
7 uint32_t a;
8 uint32_t b;
9 uint32_t c;
10 };
11 uint32_t x[3];
12}hoge_m;
13
14int main()
15{
16 uint32_t out;
17 uint32_t* hoge_pnt;
18 hoge_m hoge_bff = {{1,2,3}};
19
20 hoge_pnt = hoge_bff.x;
21 out = *hoge_pnt; //aを取り出す
22 printf("%d\n", out);
23 hoge_pnt++;
24 out = *hoge_pnt; //bを取り出す
25 printf("%d\n", out);
26 hoge_pnt++;
27 out = *hoge_pnt; //cを取り出す
28 printf("%d\n", out);
29
30 return 0;
31}