Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <stdlib.h>
  4.  
  5. struct rectangle {
  6. int x;
  7. int y;
  8. int w;
  9. int h;
  10. };
  11.  
  12. struct container {
  13. struct rectangle *r;
  14. bool foo;
  15. };
  16.  
  17. struct application {
  18. struct container c[10][10];
  19. bool bar;
  20. };
  21.  
  22. int main(void) {
  23. int x, y;
  24. struct application a;
  25.  
  26. a.bar = false;
  27.  
  28. for (x = 0; x < 10; x++) {
  29. for (y = 0; y < 10; y++) {
  30. a.c[x][y].r = malloc(sizeof (struct rectangle));
  31.  
  32. if (a.c[x][y].r == NULL) {
  33. return -1;
  34. }
  35.  
  36. a.c[x][y].r->x = 1;
  37. a.c[x][y].r->y = 1;
  38. a.c[x][y].r->w = 1;
  39. a.c[x][y].r->h = 1;
  40.  
  41. a.c[x][y].foo = true;
  42. }
  43. }
  44.  
  45. for (x = 0; x < 10; x++) {
  46. for (y = 0; y < 10; y++) {
  47. free(a.c[x][y].r);
  48. }
  49. }
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement