C语言结构体指针成员强制类型转换

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 typedef struct ListElmt_
 5 {
 6     void *data;
 7     struct ListElmt_ *next;
 8 } ListElmt;
 9 
10 int main() {
11 
12 
13     ListElmt list;
14     //char str = 'a';
15     //list.data = &str;
16     //*(list.data) = 'a';
17 
18     list.data = malloc(10);
19     *( (char *) list.data) = 'a';
20 
21 
22     printf("%c", *( (char *) list.data));
23 
24     return 0;
25 }
原文地址:https://www.cnblogs.com/ly89cn/p/9795579.html