Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct Animal {
- char * name;
- int age;
- struct Animal * mother;
- struct Animal * father;
- };
- struct Animal *
- Animal_new(char * name, int age) {
- struct Animal * self = (struct Animal *) malloc(sizeof(struct Animal));
- self->name = name;
- self->age = age;
- return self;
- }
- void
- Animal_inspect(struct Animal * self) {
- printf("%s is %d years old\n", self->name, self->age);
- }
- int
- main() {
- char foo = 'a';
- char bar = 'a';
- struct Animal * niko = Animal_new("Niko", 2);
- if (niko->age > 0 && niko->age < 100)
- Animal_inspect(niko);
- return 0;
- }
Add Comment
Please, Sign In to add comment