#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
// 使用malloc为struct Outer类型的变量动态分配内存
struct Outer *outer = (struct Outer *)malloc(sizeof(struct Outer));
if (outer == NULL) {
printf("内存分配失败\n");
return 1;
}
// 初始化inner结构体中的value为10,str为"hello"
outer->inner.value = 10;
strcpy(outer->inner.str, "hello");
// 初始化data为3.14
outer->data = 3.14;
// 打印验证
printf("inner.value: %d\n", outer->inner.value);
printf("inner.str: %s\n", outer->inner.str);
printf("data: %lf\n", outer->data);
// 释放内存
free(outer);
return 0;
}