结构体的强制类型转化(android中的代码问题)
2013-11-22 20:50
411 查看
分析一下结构体的强制类型转化,远离不太冻
/* * Copyright (c) 2013 by Giayee co.LTD * Funcion Discription * int argc: disp number of arg * char *argc[]: disp point of every arg * main: the main enter point of process * 2013-11-20 by xiezh@giayee.com */ #include "stdafx.h" struct hw_device_t{ int open; }; struct hw_hello_t{ struct hw_device_t common; int x; int y; }; void open_device(struct hw_device_t **device){ struct hw_hello_t *hello_device = (struct hw_hello_t *)malloc( sizeof(struct hw_hello_t) ); hello_device->common.open = 99; hello_device->x = 95; hello_device->y = 95; *device = &hello_device->common; } int main(int argc, char* argv[]) { struct hw_hello_t *dev = NULL; open_device( (struct hw_device_t **)&dev ); cout << dev->common.open << endl; return 0; }
相关文章推荐
- Android开发: 通过Intent 调用Camera应用 sample code
- 【总结】在两个Activity之间进行跳转时出错原因分析(二)——在AndroidManifest.xml未声明导致
- Android抽象布局——include、merge 、ViewStub
- Android之实现百度云主界面框架
- android笔记3——handler消息机制
- android笔记2——anr产生的原理以及如何避免
- Android开发23——样式和主题
- Android 项目实战视频资料 学习充电必备
- Android GraphicBuffer分配过程
- android 解决输入法键盘遮挡布局内容方法
- ADB server didn’t ACK解决
- Android开发22――广播接收者BroadcastReceiver的原理和注册
- android 中CHECK宏分析
- android之Fragment(官网资料翻译)
- 浅谈android中的目录结构
- Android getSystemService()
- android apk 反编译方法
- android超级课程表
- android application 开源代码(继续更新中)
- 获取Android版本信息和电话信息