summaryrefslogtreecommitdiff
path: root/c/structs.c
diff options
context:
space:
mode:
authorpants <niklasjo2004@gmail.com>2026-09-21 14:17:45 -0700
committerpants <niklasjo2004@gmail.com>2026-09-21 14:17:45 -0700
commita33d49ac4d1ce554c72770927957a089b4023bf1 (patch)
tree17ea036b5a0e8b488dc236f0ce48a275ecd80ef8 /c/structs.c
Diffstat (limited to 'c/structs.c')
-rw-r--r--c/structs.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/c/structs.c b/c/structs.c
new file mode 100644
index 0000000..4e8670a
--- /dev/null
+++ b/c/structs.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <string.h>
+
+struct dog {
+ int age;
+ int weight;
+ char color[16];
+ char name[16];
+};
+
+
+void menu(struct dog atlas) {
+ int option;
+
+ do {
+ printf("dawg\n");
+ printf("1. Option 1\n");
+ printf("2. Option 2\n");
+ printf("3. Option 3\n");
+ printf("4. Exit\n");
+ scanf("%d", &option);
+
+ switch (option) {
+ case 1:
+ printf("name: %s\n", atlas.name);
+ break;
+ case 2:
+ printf("age: %d\n", atlas.age);
+ break;
+ case 4:
+ printf("exiting...\n");
+ break;
+ default:
+ printf("Invalid option\n");
+ }
+ } while (option != 4);
+}
+
+int main() {
+ struct dog atlas;
+ atlas.age = 7;
+ atlas.weight = 77;
+ strcpy(atlas.color, "black");
+ strcpy(atlas.name, "atlas");
+
+ menu(atlas);
+ return 0;
+}
+