2009-05-01から1日間の記事一覧

gccで使えるサイズ0の配列ってこういうことができるってこと?

#include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> struct foobar { int length; char str[0]; }; void *xmalloc(size_t size) { void *p = malloc(size); assert(p != NULL); return p; } int main(int argc, char **argv) { struct foobar *p = NULL; int len = 0;</assert.h></stdlib.h></string.h></stdio.h>…