aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeonard Kugis <leonardkugis@gmail.com>2018-01-13 16:36:08 +0100
committerLeonard Kugis <leonardkugis@gmail.com>2018-01-13 16:36:08 +0100
commitd4c120217549f928a01ef5a69b3760851e1fda8d (patch)
treedad9e81d4918b66c67abb354788e834986c55dea /main.c
Initial commit
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..fdf3783
--- /dev/null
+++ b/main.c
@@ -0,0 +1,27 @@
+#include "blatt09_1_2.h"
+
+Student studenten[3];
+
+int main()
+{
+ studenten[0] = (Student) { "Anna" , "Musterfrau" , 22222 , "Am Schwarzenberg-Campus 3" , 4};
+ studenten[1] = (Student) { "Hans", "Peter", 44444, "Kasernenstrasse 12", 2};
+ studenten[2] = (Student) { "Lisa", "Lustig", 66666, "Denickestrasse 15", 8};
+ print_studenten();
+ printf("tausche 1 mit 3\n");
+ swap(studenten, studenten + 2);
+ print_studenten();
+}
+
+void print_studenten()
+{
+ for (u8 i = 0, sz = sizeof(studenten)/sizeof(Student); i < sz; i++)
+ printf("{\"%s\", \"%s\", %u, \"%s\", %u}\n", studenten[i].vorname, studenten[i].nachname, studenten[i].matrikelnummer, studenten[i].adresse, studenten[i].kurse);
+}
+
+void swap(Student *s1, Student *s2)
+{
+ struct student buffer = *s1;
+ *s1 = *s2;
+ *s2 = buffer;
+} \ No newline at end of file