http://www.joinc.co.kr/ 에 있는 C programming FAQs 를 읽다가 재미 있는 것을 발견했습니다.

#include <stdio.h>
#include <malloc.h>
#include <string.h>

struct Foo{
int bar;
char chs[1];
};

int main()
{

struct Foo * pFoo;

pFoo = (struct Foo *)
malloc( (sizeof(struct Foo)+1) + strlen("Test") );
strcpy( pFoo->chs , "Test");
printf("%s\n", pFoo->chs);

free(pFoo);
return 0;
}
의도적으로 메모리 동적할당을 구조체 크기보다 더 크게 생성시켰습니다. 이런식으로 만들어 두면 구조체의 마지막 멤버를 유연하게 크기를 조절할 수 있습니다. C99 에서는 구조체를 다음처럼 선언하면 되는 것 같군요.

struct Foo{
int bar;
char chs[]; // chs[1] 에서 chs[] 로 바꾸었습니다.
};