fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct hoge {
  5. int i;
  6. char c[];
  7. };
  8.  
  9. int main()
  10. {
  11. struct hoge *p;
  12. char s[] = "hoge";
  13.  
  14. p = malloc(sizeof (struct hoge) + sizeof s);
  15. p->i = strlen(s);
  16. strcpy(p->c, s);
  17.  
  18. printf("%d %s\n", p->i, p->c);
  19.  
  20. free(p);
  21. }
  22.  
Success #stdin #stdout 0.01s 1852KB
stdin
Standard input is empty
stdout
4 hoge