<span style="font-size:18px;">这里和大家分享下以下类型转换的编译器的行为,以其用法。</span>
例:
struct in
{
int a;
}
struct test
{
struct in* i;
int b;
}
void func()
{
struct test t;
void *v = &t;
struct in *i;
i = *(struct in**)v;</span>
}
1、对v类型进行强制转换成struct in*的地址。其值保存的为struct in*
2、*取struct in*的值,也就是i的值
从上面可以看出强制类型转换其实是让编译器把内存中的值强制为我们所需要的类型。从而方便使用。