可以将一个数组强制转换成结构体么?
typdef struct A{char b;long int c;) R;char content[5];
(R) content[5];
可以不可以
#include <stdio.h> int main(void) { typedef struct A { char b; long int c; } R; R content; content.b = 'A'; char *read = (char *)&content; printf("%c\n", read[0]); return 0; }
#include <stdio.h> #include <stdlib.h> typedef struct{ int x; }eg; char database[32]; int main() { eg *para = (eg*)database; printf("%d\n",sizeof(int)); printf("%d\n",sizeof(char)); printf("%x\n",¶[0]); printf("%x\n",¶[1]); printf("%x\n",¶[2]); printf("%x\n",¶[3]); printf("%x\n",&database[0]); printf("%x\n",&database[4]); printf("%x\n",&database[8]); printf("%x\n",&database[12]); }