fork download
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. typedef struct {
  6. char title[55];
  7. char *author;
  8. int pages;
  9. } Book;
  10.  
  11. typedef struct {
  12. int numBooks;
  13. Book *books[22];
  14. } Shelf;
  15.  
  16. int main(void) {
  17. Shelf bookShelf[11];
  18. Book book;
  19. bookShelf[3].books[7] = &book;
  20. bookShelf[3].books[7]->author = malloc(sizeof(char) * 50);
  21. strcpy(bookShelf[3].books[7]->author, "Seuss");
  22. printf(bookShelf[3].books[7]->author);
  23. }
Success #stdin #stdout 0s 5364KB
stdin
Standard input is empty
stdout
Seuss