summaryrefslogtreecommitdiff
path: root/simclist-1.5/examples/ex1.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-08-03 19:22:36 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-08-03 19:22:36 +0200
commit853bbb3752a5fa2f58ef456ffb6e3a552e13cb11 (patch)
treece49a533f82a42a65fa6a4771a7b8fbfe33798cf /simclist-1.5/examples/ex1.c
initial commit
Diffstat (limited to 'simclist-1.5/examples/ex1.c')
-rw-r--r--simclist-1.5/examples/ex1.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/simclist-1.5/examples/ex1.c b/simclist-1.5/examples/ex1.c
new file mode 100644
index 0000000..13c67c3
--- /dev/null
+++ b/simclist-1.5/examples/ex1.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+#include <simclist.h> /* use the SimCList library */
+
+
+int main() {
+ list_t mylist; /* declare a list */
+ int userval;
+
+
+ list_init(& mylist); /* initialize the list */
+
+ printf("Insert your number: ");
+ scanf("%d", & userval);
+
+ list_append(& mylist, & userval); /* add an element to the list */
+
+ printf("The list now holds %u elements.\n", \
+ list_size(& mylist)); /* get the size of the list */
+
+ printf("Your number was: %d\n", \
+ * (int*)list_get_at(& mylist, 0)); /* extract the first element of the list */
+
+ list_destroy(&mylist);
+
+ return 0;
+}
+