一个强制转换问题
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int a;
int b;
char c;
char f;
}mystruct;
int main() {
unsigned char *buffer[100];
mystruct *test = (mystruct *)buffer;
int i;
for(i=0;i<5;i++){
test[i].a=0;
test[i].b=1;
test[i].c='2';
test[i].f=‘2’;
}
return 0;
}
我不理解的是为什么红色部分可以强制转换,buffer是一个放有100个字符指针的数组,
转换为一个结构指针,但结构指针里面的成员和字符串指针并不能匹配啊?