From 3681cffbb573020ec317c9de633bf960ec433bf9 Mon Sep 17 00:00:00 2001 From: Peace Date: Thu, 24 Apr 2025 11:15:48 +0900 Subject: [PATCH] struct --- basic/6_struct.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 basic/6_struct.c diff --git a/basic/6_struct.c b/basic/6_struct.c new file mode 100644 index 0000000..43785e7 --- /dev/null +++ b/basic/6_struct.c @@ -0,0 +1,17 @@ +#include + +struct Person +{ + char name[50]; + int age; + float height; +}; + +int main() +{ + struct Person person = { "Alice", 30, 170.5 }; + + printf("Name: %s\n", person.name); + printf("Age: %d\n", person.age); + printf("Height: %.2f\n", person.height); +}