标签:
工作多年,C语言基础还是不扎实,惭愧!
1、结构体指针嵌套
#include<stdlib.h> #include<stdio.h> #include<stdint.h> int main() { uint8_t test[8]={1}; struct b_t { uint8_t *data; }; struct a_t { struct b_t *b; }; struct a_t *a = (struct a_t*)malloc(sizeof(struct a_t)); a->b = (struct b_t*)malloc(sizeof(struct b_t)); a->b->data = malloc(8*sizeof(uint8_t)); a->b->data = test; printf("%d\r\n",*(a->b->data)); return 0; }
缺什么补什么...
标签:
原文地址:http://www.cnblogs.com/dong1/p/5843185.html