柔性数组成员疑问
supermegaboy博文 http://blog.csdn.net/supermegaboy/article/details/4854939
阐述了柔性数组成员的使用,想请教下内存释放的问题。如下
#pragma pack(1)struct test{ int a; double b; char c[];};#pragma pack()int main(){ char a[] = "hello world"; struct test *PntTest = (struct test* )malloc(sizeof(struct test) + strlen(a) + 1); strcpy(PntTest->c, a); free(PntTest->c); //此释放是否需要? free(PntTest); //此处到底free了多少,理论应该是sizeof(struct test)吧? return 0;}