fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct __attribute__((__packed__)) weird_struct
  6. {
  7. int some;
  8. unsigned char value[1];
  9. };
  10.  
  11. int main(void)
  12. {
  13. unsigned char text[] = "Allie has a cat";
  14. struct weird_struct *ws =
  15. malloc(sizeof(struct weird_struct) + sizeof(text) - 1);
  16. ws->some = 5;
  17. strcpy(ws->value, text);
  18. printf("some = %d, value = %s\n", ws->some, ws->value);
  19. free(ws);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
some = 5, value = Allie has a cat