From ec4545806552880edad3e1e609060b93652bb925 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Tue, 7 May 2024 20:59:53 -0400 Subject: initialize the struct --- booki.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/booki.c b/booki.c index 83858e9..96d42a9 100644 --- a/booki.c +++ b/booki.c @@ -17,6 +17,8 @@ struct es { char* ptr; }; +struct es default_es = { 0, NULL }; + struct Book { struct es id; struct es title; @@ -32,6 +34,20 @@ struct Book { //struct es translators[MAX_TRANSLATORS]; }; +struct Book new_book() { + struct Book book; + book.id = default_es; + book.title = default_es; + book.author = default_es; + book.pages = 0; + book.isbn = default_es; + struct es language = { 7, "English" }; // default language + book.language = language; + book.translator = default_es; + book.published = 0; + return book; +} + char* BOOKI_FILE; int PARSE_LINE = 1; @@ -45,7 +61,7 @@ const char* get_last_word(const char* str) { } struct Book parse_book(char* current_pos) { - struct Book book; + struct Book book = new_book(); char* attr; char* value; char c = *current_pos; -- cgit v1.2.3