您的位置:首页 > 其它

C中,在struct中,得到一个可变大小的数组

2006-10-15 17:56 369 查看
#include <stdio.h>

struct xx{
int i;
char st[1];
};

int main()
{
char s1[]="abc";
struct xx *a=(struct xx*)malloc(sizeof(struct xx)+strlen(s1)+1);
strcpy(a->st, s1);
printf("%s ", a->st);
free(a);
getch();
return 0;
}

详细内容见《深度探索C++对象模型》P19

http://community.csdn.net/Expert/topic/5054/5054882.xml?temp=.9214289
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐