diff options
-rw-r--r-- | .gitignore | 24 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | defs.h | 9 | ||||
-rw-r--r-- | main.c | 27 | ||||
-rw-r--r-- | main.h | 18 |
5 files changed, 86 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4be1f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +*.com +*.class +*.dll +*.exe +*.o +*.so +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip +*.log +*.sql +*.sqlite +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5a3d29f --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +CC = gcc +CFLAGS = -std=c99 -pedantic -Wall -Wextra + +all: blatt09_1_2.exe +blatt09_1_2.exe: blatt09_1_2.o + $(CC) $(CFLAGS) -o blatt09_1_2.exe blatt09_1_2.o +blatt09_1_2.o: blatt09_1_2.c blatt09_1_2.h defs.h + $(CC) $(CFLAGS) -c blatt09_1_2.c
\ No newline at end of file @@ -0,0 +1,9 @@ +#ifndef DEFS +#define DEFS + +#include <stdio.h> + +typedef unsigned char u8; +typedef unsigned long int u32; + +#endif
\ No newline at end of file @@ -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 @@ -0,0 +1,18 @@ +#ifndef BLATT09_1_2 +#define BLATT09_1_2 + +#include "defs.h" + +typedef struct student{ + char *vorname; + char *nachname; + u32 matrikelnummer; + char *adresse; + u8 kurse; +} Student; + +int main(); +void print_studenten(); +void swap(Student *s1, Student *s2); + +#endif
\ No newline at end of file |