encapsulate print, method-style

This commit is contained in:
Loic Nageleisen 2013-02-01 10:28:40 +01:00
parent 6a6cbef986
commit cbe43f63fd

6
main.c
View file

@ -17,13 +17,17 @@ void Post_init(Post *self) {
*self->body = '\0'; *self->body = '\0';
} }
void Post_printf(Post *self) {
printf("%s\n\n%s\n", self->author, self->body);
}
void Post_dealloc(Post *self) { void Post_dealloc(Post *self) {
free(self); free(self);
} }
int main(void) { int main(void) {
Post *post = Post_alloc(); Post *post = Post_alloc();
printf("%s\n\n%s\n", post->author, post->body); Post_printf(post);
Post_dealloc(post); Post_dealloc(post);
return 0; return 0;
} }