diff --git a/Demonstration/Demonstration.vcxproj b/Demonstration/Demonstration.vcxproj
index 6f29ba4..b3d1ca5 100644
--- a/Demonstration/Demonstration.vcxproj
+++ b/Demonstration/Demonstration.vcxproj
@@ -142,6 +142,7 @@
+
@@ -152,6 +153,9 @@
{43c12dd0-611c-43ee-82f4-f25b33eed30b}
+
+
+
diff --git a/Demonstration/Demonstration.vcxproj.filters b/Demonstration/Demonstration.vcxproj.filters
index 87fef6a..73f3369 100644
--- a/Demonstration/Demonstration.vcxproj.filters
+++ b/Demonstration/Demonstration.vcxproj.filters
@@ -18,5 +18,13 @@
Quelldateien
+
+ Quelldateien
+
+
+
+
+ Headerdateien
+
\ No newline at end of file
diff --git a/Demonstration/book.c b/Demonstration/book.c
new file mode 100644
index 0000000..02d215c
--- /dev/null
+++ b/Demonstration/book.c
@@ -0,0 +1,35 @@
+#include "book.h"
+
+#include
+#include
+#include
+
+Book* book_create(const char* title, const char* author, int year)
+{
+ // initialize book
+ Book* book = calloc(1, sizeof(Book));
+ if (!book)
+ {
+ return NULL;
+ }
+
+ // initialize title and author
+ book->title = calloc(strlen(title), sizeof(char));
+ book->author = calloc(strlen(author), sizeof(char));
+ if (!book->title || !book->author)
+ {
+ return NULL;
+ }
+
+ strcpy(book->title, title);
+ strcpy(book->author, author);
+ book->year = year;
+
+ return book;
+}
+
+void book_print(const void* data)
+{
+ const Book* book = (Book*)data;
+ printf("Book[title=%s,author=%s,year=%d]\n", book->title, book->author, book->year);
+}
\ No newline at end of file
diff --git a/Demonstration/book.h b/Demonstration/book.h
new file mode 100644
index 0000000..a43be45
--- /dev/null
+++ b/Demonstration/book.h
@@ -0,0 +1,11 @@
+#pragma once
+
+typedef struct {
+ char* title;
+ char* author;
+ int year;
+} Book;
+
+Book* book_create(const char* title, const char* author, int year);
+
+void book_print(const void* data);
\ No newline at end of file
diff --git a/Demonstration/main.c b/Demonstration/main.c
index 330d7c7..52e2bb7 100644
--- a/Demonstration/main.c
+++ b/Demonstration/main.c
@@ -1,45 +1,9 @@
#include
#include
-#include
#include "../Implementation/linked_list.h"
#include "../../MenuLib/menu.h"
-
-typedef struct {
- char* title;
- char* author;
- int year;
-} Book;
-
-Book* book_create(const char* title, const char* author, int year)
-{
- // initialize book
- Book* book = calloc(1, sizeof(Book));
- if (!book)
- {
- return NULL;
- }
-
- // initialize title and author
- book->title = calloc(strlen(title), sizeof(char));
- book->author = calloc(strlen(author), sizeof(char));
- if (!book->title || !book->author)
- {
- return NULL;
- }
-
- strcpy(book->title, title);
- strcpy(book->author, author);
- book->year = year;
-
- return book;
-}
-
-void book_print(const void* data)
-{
- const Book* book = (Book*)data;
- printf("Book[title=%s,author=%s,year=%d]\n", book->title, book->author, book->year);
-}
+#include "book.h"
void show_push(Node** list)
{
@@ -85,7 +49,7 @@ void show_insert(Node** list)
printf("Enter place after which book is inserted: ");
scanf_s(" %d", &index);
- list_insert(list_get(list, index), book_create(title, author, year));
+ list_insert(list_get(*list, index), book_create(title, author, year));
}
void show_print(Node** list)
@@ -98,7 +62,7 @@ void show_get(Node** list)
int index;
printf("Enter place: ");
scanf_s(" %d", &index);
- list_print(list_get(list,index), &book_print);
+ list_print(list_get(*list,index), &book_print);
}
void show_remove(Node** list)
@@ -106,7 +70,7 @@ void show_remove(Node** list)
int index;
printf("Enter place: ");
scanf_s(" %d", &index);
- list_remove(list_get(list, index));
+ list_remove(list_get(*list, index));
}
@@ -121,7 +85,7 @@ void main(void)
{"Print item", '4', (void*)&show_print, &list},
{"Look at item by index", '5', (void*)&show_get, &list},
{"Remove item by index", '6', (void*)&show_remove, &list},
- {"BLANK", NULL, NULL, NULL},
+ {"BLANK", ' ', NULL, NULL},
{"Quit", 'q', (void*)&exit, NULL}
};
struct MenuPage pages[] = {