Guest User

Untitled

a guest
Apr 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct Animal {
  5. char * name;
  6. int age;
  7. struct Animal * mother;
  8. struct Animal * father;
  9. };
  10.  
  11. struct Animal *
  12. Animal_new(char * name, int age) {
  13. struct Animal * self = (struct Animal *) malloc(sizeof(struct Animal));
  14. self->name = name;
  15. self->age = age;
  16. return self;
  17. }
  18.  
  19. void
  20. Animal_inspect(struct Animal * self) {
  21. printf("%s is %d years old\n", self->name, self->age);
  22. }
  23.  
  24. int
  25. main() {
  26. char foo = 'a';
  27. char bar = 'a';
  28. struct Animal * niko = Animal_new("Niko", 2);
  29. if (niko->age > 0 && niko->age < 100)
  30. Animal_inspect(niko);
  31. return 0;
  32. }
Add Comment
Please, Sign In to add comment