basic object-like system in C

This commit is contained in:
Loic Nageleisen 2013-02-01 10:24:07 +01:00
commit 6a6cbef986
3 changed files with 37 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
main
*.o

6
Makefile Normal file
View file

@ -0,0 +1,6 @@
all: main
main: main.o
clean:
rm -f main.o main

29
main.c Normal file
View file

@ -0,0 +1,29 @@
#include <stdlib.h>
#include <stdio.h>
#include <Block.h>
struct Post_s {
char author[255];
char body[2048];
};
typedef struct Post_s Post;
Post *Post_alloc() {
return malloc(sizeof(Post));
}
void Post_init(Post *self) {
*self->author = '\0';
*self->body = '\0';
}
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_dealloc(post);
return 0;
}