1 #include <stdlib.h> 2 #include <string.h> 3 4 struct WithFlexChar { 5 int member; 6 char flexible[]; 7 }; 8 9 struct WithFlexSChar { 10 int member; 11 signed char flexible[]; 12 }; 13 14 struct WithFlexUChar { 15 int member; 16 unsigned char flexible[]; 17 }; 18 19 #define CONTENTS "contents" 20 main()21int main() { 22 struct WithFlexChar *c = 23 (struct WithFlexChar *)malloc(sizeof(int) + sizeof(CONTENTS)); 24 c->member = 1; 25 strcpy(c->flexible, CONTENTS); 26 27 struct WithFlexSChar *sc = 28 (struct WithFlexSChar *)malloc(sizeof(int) + sizeof(CONTENTS)); 29 sc->member = 1; 30 strcpy((char *)sc->flexible, CONTENTS); 31 32 struct WithFlexUChar *uc = 33 (struct WithFlexUChar *)malloc(sizeof(int) + sizeof(CONTENTS)); 34 uc->member = 1; 35 strcpy((char *)uc->flexible, CONTENTS); 36 return 0; // break here 37 } 38