c语言柔性数组

来源:互联网 发布:虬髯客 知乎 编辑:程序博客网 时间:2024/04/30 08:59

http://www.2cto.com/kf/201404/293519.html



#include "stdio.h"

struct st_type{    int i;int a[];};void main(void){struct st_type *st_p =(struct st_type *)malloc(sizeof(struct st_type)+100*sizeof(int));st_p->i=10;memcpy(st_p->a,"i love you!!!!!!",20);printf("%d %s\r\n",st_p->i,st_p->a);}

10 i love you!!!!!!
Press any key to continue

0 0