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 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM