From cbe43f63fda95fe0d914749e48b97bb30dc7ec8b Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Fri, 1 Feb 2013 10:28:40 +0100 Subject: [PATCH] encapsulate print, method-style --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 3d64d12..d0e237e 100644 --- a/main.c +++ b/main.c @@ -17,13 +17,17 @@ void Post_init(Post *self) { *self->body = '\0'; } +void Post_printf(Post *self) { + printf("%s\n\n%s\n", self->author, self->body); +} + void Post_dealloc(Post *self) { free(self); } int main(void) { Post *post = Post_alloc(); - printf("%s\n\n%s\n", post->author, post->body); + Post_printf(post); Post_dealloc(post); return 0; }