天天看點

c語言柔性數組

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

繼續閱讀