diff --git a/20211025/fhello-1.c b/20211025/fhello-1.c new file mode 100644 index 0000000000000000000000000000000000000000..6548d9c81c73a7f3da8b1b2e62290bc8029d11f0 --- /dev/null +++ b/20211025/fhello-1.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20211025/fhello-10.c b/20211025/fhello-10.c new file mode 100644 index 0000000000000000000000000000000000000000..4598debd670153f3d8bfdd1d33b83372a2da30e4 --- /dev/null +++ b/20211025/fhello-10.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <errno.h> +#include <string.h> + +int main (void) +{ + FILE *f = fopen ("/irgendwo/fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + else + { + char *msg = strerror (errno); + fprintf (stderr, "%s\n", msg); + } + return 0; +} diff --git a/20211025/fhello-11.c b/20211025/fhello-11.c new file mode 100644 index 0000000000000000000000000000000000000000..2719776d312c79509d2863c5eabce09236db255c --- /dev/null +++ b/20211025/fhello-11.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <errno.h> +#include <string.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + else + { + char *msg = strerror (errno); + fprintf (stderr, "%s\n", msg); + } + return 0; +} diff --git a/20211025/fhello-12.c b/20211025/fhello-12.c new file mode 100644 index 0000000000000000000000000000000000000000..2b389ec060abcb3cfc727f1ec390bcbc9cc5e44e --- /dev/null +++ b/20211025/fhello-12.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <errno.h> +#include <string.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; + } + else + { + char *msg = strerror (errno); + fprintf (stderr, "%s\n", msg); + return 1; + } +} diff --git a/20211025/fhello-13.c b/20211025/fhello-13.c new file mode 100644 index 0000000000000000000000000000000000000000..d96528efa65d9fa0b952f43cf51d4bd5c6b266b5 --- /dev/null +++ b/20211025/fhello-13.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <errno.h> +#include <string.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; + } + else + { + char *msg = strerror (errno); + fprintf (stderr, "%s\n", msg); + return errno; + } +} diff --git a/20211025/fhello-14.c b/20211025/fhello-14.c new file mode 100644 index 0000000000000000000000000000000000000000..383cb352d1973225aaeef9c01373c879a10fd433 --- /dev/null +++ b/20211025/fhello-14.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + if (!f) + error (errno, errno, "cannot open file"); + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20211025/fhello-15.c b/20211025/fhello-15.c new file mode 100644 index 0000000000000000000000000000000000000000..6d48fa46b42e7a1304d40f7520becc1d823abe4e --- /dev/null +++ b/20211025/fhello-15.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + char *filename = "fhello.txt"; + FILE *f = fopen (filename, "w"); + if (!f) + { + char buffer[100]; + sprintf (buffer, "cannot open file \"%s\"", filename); + error (errno, errno, buffer); + } + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20211025/fhello-16.c b/20211025/fhello-16.c new file mode 100644 index 0000000000000000000000000000000000000000..c4a15cfc7f302711cb62fe3142c64a4a9bf8bae4 --- /dev/null +++ b/20211025/fhello-16.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + char *filename = "fhello.txt"; + FILE *f = fopen (filename, "w"); + if (!f) + { + char buffer[5]; + sprintf (buffer, "cannot open file \"%s\"", filename); + error (errno, errno, buffer); + } + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20211025/fhello-17.c b/20211025/fhello-17.c new file mode 100644 index 0000000000000000000000000000000000000000..1e669e43f5ff1921e736d355c9c07a29059a3c3d --- /dev/null +++ b/20211025/fhello-17.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + char *filename = "fhello.txt"; + FILE *f = fopen (filename, "w"); + if (!f) + { + char buffer[5]; + snprintf (buffer, 5, "cannot open file \"%s\"", filename); + error (errno, errno, buffer); + } + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20211025/fhello-18.c b/20211025/fhello-18.c new file mode 100644 index 0000000000000000000000000000000000000000..2415b605e41b459e13abd1874ee05b52c9650f98 --- /dev/null +++ b/20211025/fhello-18.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + char *filename = "fhello.txt"; + FILE *f = fopen (filename, "w"); + if (!f) + { + char buffer[5]; + snprintf (buffer, 5, "cannot open file \"%s\"", filename); + buffer[4] = 0; + error (errno, errno, buffer); + } + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20211025/fhello-2.c b/20211025/fhello-2.c new file mode 100644 index 0000000000000000000000000000000000000000..54818197f8eb27e3f8254df6f156882c978aa5d7 --- /dev/null +++ b/20211025/fhello-2.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + fprintf (f, "Hello, world!\n"); + return 0; +} diff --git a/20211025/fhello-3.c b/20211025/fhello-3.c new file mode 100644 index 0000000000000000000000000000000000000000..c8d325db47744b5eab8f1ce41b3ff2ee32805451 --- /dev/null +++ b/20211025/fhello-3.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <unistd.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + fprintf (f, "Hello, world!\n"); + sleep (60); + return 0; +} diff --git a/20211025/fhello-4.c b/20211025/fhello-4.c new file mode 100644 index 0000000000000000000000000000000000000000..6c59dbb56cf748d8f3215f0c12112a10307b52f8 --- /dev/null +++ b/20211025/fhello-4.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <unistd.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + fprintf (f, "Hello, world!\n"); + fclose (f); + sleep (60); + return 0; +} diff --git a/20211025/fhello-5.c b/20211025/fhello-5.c new file mode 100644 index 0000000000000000000000000000000000000000..e60488586def943dca122a11c35369724189102d --- /dev/null +++ b/20211025/fhello-5.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <unistd.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + fprintf (f, "Hello, world!\n"); + sleep (60); + fclose (f); + return 0; +} diff --git a/20211025/fhello-6.c b/20211025/fhello-6.c new file mode 100644 index 0000000000000000000000000000000000000000..cff257e0ff158ce359262f410f609f90c38e2985 --- /dev/null +++ b/20211025/fhello-6.c @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <unistd.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + fprintf (f, "Hello, world!\n"); + fflush (f); + sleep (60); + fclose (f); + return 0; +} diff --git a/20211025/fhello-7.c b/20211025/fhello-7.c new file mode 100644 index 0000000000000000000000000000000000000000..be795a3562532f0987fe9adf28b29e5a69912d8a --- /dev/null +++ b/20211025/fhello-7.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <unistd.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + return 0; +} diff --git a/20211025/fhello-8.c b/20211025/fhello-8.c new file mode 100644 index 0000000000000000000000000000000000000000..529ddffd80d4a17c9fc89bf07f9da2368f412ea3 --- /dev/null +++ b/20211025/fhello-8.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <errno.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + else + fprintf (stderr, "error #%d\n", errno); + return 0; +} diff --git a/20211025/fhello-9.c b/20211025/fhello-9.c new file mode 100644 index 0000000000000000000000000000000000000000..7242a4884b1f60b6b080a4592e474dbf6886ac26 --- /dev/null +++ b/20211025/fhello-9.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <errno.h> + +int main (void) +{ + FILE *f = fopen ("/irgendwo/fhello.txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + else + fprintf (stderr, "error #%d\n", errno); + return 0; +} diff --git a/20211025/hp-20211025.pdf b/20211025/hp-20211025.pdf index b99f2f6716dff85543d90e9dde0917cb7688e95d..7c5e6c87aa135dd8447b70c087e7ebc406f5bb98 100644 Binary files a/20211025/hp-20211025.pdf and b/20211025/hp-20211025.pdf differ diff --git a/20211025/hp-20211025.tex b/20211025/hp-20211025.tex index e14ab656150850d32c79be29d453e05c32b1b6e4..2f8fae5cccc2d046fb0716a2fed98f2c349516ed 100644 --- a/20211025/hp-20211025.tex +++ b/20211025/hp-20211025.tex @@ -688,7 +688,7 @@ { FILE *f = fopen ("fhello.txt", "w"); if (!f) - error (1, errno, "cannot open file"); + error (errno, errno, "cannot open file"); fprintf (f, "Hello, world!\n"); fclose (f); return 0; diff --git a/20211025/pointers-1.c b/20211025/pointers-1.c new file mode 100644 index 0000000000000000000000000000000000000000..6e19ec4ef5e5b81e940168a4a4e6b3026a4f4375 --- /dev/null +++ b/20211025/pointers-1.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + int prime[] = { 2, 3, 5, 7, 11, 0 }; + for (int *p = prime; *p; p++) + printf ("%d\n", *p); + return 0; +} diff --git a/20211025/pointers-2.c b/20211025/pointers-2.c new file mode 100644 index 0000000000000000000000000000000000000000..6c38a2ade74ffce8a45164757a9f33051c04f3c6 --- /dev/null +++ b/20211025/pointers-2.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + int prime[] = { 2, 3, 5, 7, 11, ',' }; + for (int *p = prime; *p != ','; p++) + printf ("%d\n", *p); + return 0; +} diff --git a/20211025/pointers-3.c b/20211025/pointers-3.c new file mode 100644 index 0000000000000000000000000000000000000000..811af51f07e06981b5e1af1ad8cf632a292bfd38 --- /dev/null +++ b/20211025/pointers-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + int prime[] = { 2, 3, 44, 5, 7, 11, ',' }; + for (int *p = prime; *p != ','; p++) + printf ("%d\n", *p); + return 0; +} diff --git a/20211025/pointers-4.c b/20211025/pointers-4.c new file mode 100644 index 0000000000000000000000000000000000000000..811af51f07e06981b5e1af1ad8cf632a292bfd38 --- /dev/null +++ b/20211025/pointers-4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + int prime[] = { 2, 3, 44, 5, 7, 11, ',' }; + for (int *p = prime; *p != ','; p++) + printf ("%d\n", *p); + return 0; +} diff --git a/20211025/sprintf-1.c b/20211025/sprintf-1.c new file mode 100644 index 0000000000000000000000000000000000000000..a6aece3afb4dcf06c4e150b9ebf92405d9e4aa36 --- /dev/null +++ b/20211025/sprintf-1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char buffer[100]; + snprintf (buffer, 100, "Die Antwort lautet: %d", 42); + buffer[99] = 0; + printf ("%s\n", buffer); + return 0; +} diff --git a/20211025/sprintf-2.c b/20211025/sprintf-2.c new file mode 100644 index 0000000000000000000000000000000000000000..56857f03d5bb3f55dcc2f3e514a867d0a5934c19 --- /dev/null +++ b/20211025/sprintf-2.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char buffer[10]; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + return 0; +} diff --git a/20211025/sprintf-3.c b/20211025/sprintf-3.c new file mode 100644 index 0000000000000000000000000000000000000000..08ef25cac45a0072e6af6b982771fe158ef2e989 --- /dev/null +++ b/20211025/sprintf-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char buffer[10]; + snprintf (buffer, 10, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + return 0; +} diff --git a/20211025/sprintf-4.c b/20211025/sprintf-4.c new file mode 100644 index 0000000000000000000000000000000000000000..1d20ed31f0a65d4dccc5e75d05d1217737ee7a75 --- /dev/null +++ b/20211025/sprintf-4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char buffer[10]; + int written = snprintf (buffer, 10, "Die Antwort lautet: %d", 42); + printf ("%s (%d characters written)\n", buffer, written); + return 0; +} diff --git a/20211025/sprintf-5.c b/20211025/sprintf-5.c new file mode 100644 index 0000000000000000000000000000000000000000..b77ad31f658f5c227360977c2f06e6e81e7afc18 --- /dev/null +++ b/20211025/sprintf-5.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char buffer[10]; + int written = snprintf (buffer, 10, "Antw: %s", "zweiundvierzig"); + printf ("%s (%d characters written)\n", buffer, written); + return 0; +} diff --git a/20211025/strings-1.c b/20211025/strings-1.c new file mode 100644 index 0000000000000000000000000000000000000000..81bc3cda8affb6268786ac989dd2907d9a84783a --- /dev/null +++ b/20211025/strings-1.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + for (char *p = hello; *p; p++) + printf ("%d", *p); + return 0; +} diff --git a/20211025/strings-10.c b/20211025/strings-10.c new file mode 100644 index 0000000000000000000000000000000000000000..c1cf30ab487da270b9b2efb229ddefd1315f61d9 --- /dev/null +++ b/20211025/strings-10.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = { 72, 101, 108, 108, 111, 10, 0 }; + printf ("%s", hello); + return 0; +} diff --git a/20211025/strings-11.c b/20211025/strings-11.c new file mode 100644 index 0000000000000000000000000000000000000000..c75e8485434dd0f3578ad93e7c574f466424e544 --- /dev/null +++ b/20211025/strings-11.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!\n"; + printf ("%s", hello); + return 0; +} diff --git a/20211025/strings-12.c b/20211025/strings-12.c new file mode 100644 index 0000000000000000000000000000000000000000..aa6c6a2164fbb8e585983d79b78bd2bc505901ff --- /dev/null +++ b/20211025/strings-12.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello.\n"; + printf ("%s", hello); + hello[1] = 'a'; + printf ("%s", hello); + return 0; +} diff --git a/20211025/strings-13.c b/20211025/strings-13.c new file mode 100644 index 0000000000000000000000000000000000000000..175c90317c50540897d99fe65a4a6863a30a9e58 --- /dev/null +++ b/20211025/strings-13.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello.\n"; + printf ("%s", hello); + hello[1] = 'a'; + printf ("%s", hello); + return 0; +} diff --git a/20211025/strings-14.c b/20211025/strings-14.c new file mode 100644 index 0000000000000000000000000000000000000000..94871b3755a657a581aef81a8658dd779abb1fd5 --- /dev/null +++ b/20211025/strings-14.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (void) +{ + printf ("\x4a\x5f\x4b\x75\x6e\x69\x63\x6b\x65\n"); + return 0; +} diff --git a/20211025/strings-15.c b/20211025/strings-15.c new file mode 100644 index 0000000000000000000000000000000000000000..cd8371a0209a4e50d45f58e70f8e96f745805cd9 --- /dev/null +++ b/20211025/strings-15.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (void) +{ + printf ("\x4a\x5f\x4b\x75\x6e\x69\x63\x6b\x65\x0a"); + return 0; +} diff --git a/20211025/strings-16.c b/20211025/strings-16.c new file mode 100644 index 0000000000000000000000000000000000000000..29dd1cbfd31fea3db44b6dd81205b6f829451e83 --- /dev/null +++ b/20211025/strings-16.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char name[] = { 0x74, 0x65, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x67, 0 }; + printf ("%s\n", name); + return 0; +} diff --git a/20211025/strings-17.c b/20211025/strings-17.c new file mode 100644 index 0000000000000000000000000000000000000000..6506b08873cd264bc3efa0e126aa0829c54dd56d --- /dev/null +++ b/20211025/strings-17.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char *name = { 0x74, 0x65, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x67, 0 }; + printf ("%s\n", name); + return 0; +} diff --git a/20211025/strings-2.c b/20211025/strings-2.c new file mode 100644 index 0000000000000000000000000000000000000000..4df32974a15ef2752512cc8b9889381b5a0917cd --- /dev/null +++ b/20211025/strings-2.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + for (char *p = hello; *p; p++) + printf ("%c", *p); + return 0; +} diff --git a/20211025/strings-3.c b/20211025/strings-3.c new file mode 100644 index 0000000000000000000000000000000000000000..0e62e1e346091fab3da99c27973f54552eca2b5e --- /dev/null +++ b/20211025/strings-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + for (char *p = hello; *p; p++) + printf ("%x", *p); + return 0; +} diff --git a/20211025/strings-4.c b/20211025/strings-4.c new file mode 100644 index 0000000000000000000000000000000000000000..ca99a886dc567e2ec28391d6284697298f996fd9 --- /dev/null +++ b/20211025/strings-4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + for (char *p = hello; *p; p++) + printf ("%02x", *p); + return 0; +} diff --git a/20211025/strings-5.c b/20211025/strings-5.c new file mode 100644 index 0000000000000000000000000000000000000000..12f486759dba62e999237775165da478d41dd3e6 --- /dev/null +++ b/20211025/strings-5.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 72, 101, 108, 108, 111, 0 }; + for (char *p = hello; *p; p++) + printf ("%02x", *p); + return 0; +} diff --git a/20211025/strings-6.c b/20211025/strings-6.c new file mode 100644 index 0000000000000000000000000000000000000000..d77f7e762d4d25a4facebfbfbeb6aeb9abade0d8 --- /dev/null +++ b/20211025/strings-6.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 72, 101, 108, 108, 111, 10, 0 }; + for (char *p = hello; *p; p++) + printf ("%c", *p); + return 0; +} diff --git a/20211025/strings-7.c b/20211025/strings-7.c new file mode 100644 index 0000000000000000000000000000000000000000..76edbc52b5ffccd44d3451b199a93d23d740f6b5 --- /dev/null +++ b/20211025/strings-7.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void) +{ + printf ("2 hoch 6 = %d\n", '@'); +} diff --git a/20211025/strings-8.c b/20211025/strings-8.c new file mode 100644 index 0000000000000000000000000000000000000000..68227c25325d9699430cacc3d071c5dad629fb40 --- /dev/null +++ b/20211025/strings-8.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + printf ("%s", hello); + return 0; +} diff --git a/20211025/strings-9.c b/20211025/strings-9.c new file mode 100644 index 0000000000000000000000000000000000000000..9b559e5cbe8e471fd294d0fea5d6ac365c69cd74 --- /dev/null +++ b/20211025/strings-9.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 72, 101, 108, 108, 111, 10, 0 }; + printf ("%s", hello); + return 0; +} diff --git a/20211025/structs-1.c b/20211025/structs-1.c new file mode 100644 index 0000000000000000000000000000000000000000..b83293df1ffb733d81170ec4aa00d890547cd644 --- /dev/null +++ b/20211025/structs-1.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { 18, 10, 2021 }; + printf ("%d.%d.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-10.c b/20211025/structs-10.c new file mode 100644 index 0000000000000000000000000000000000000000..a8f63e9b33c2d04557a06a0748d24908c0805555 --- /dev/null +++ b/20211025/structs-10.c @@ -0,0 +1,42 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; + print_date (&today); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-11.c b/20211025/structs-11.c new file mode 100644 index 0000000000000000000000000000000000000000..39adf5da52b9412929e0e64b6b87c9ba123b10e2 --- /dev/null +++ b/20211025/structs-11.c @@ -0,0 +1,42 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; + print_date (&d); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-12.c b/20211025/structs-12.c new file mode 100644 index 0000000000000000000000000000000000000000..cb560f2fc00a12292f8f00f37af1a127d1ba1c60 --- /dev/null +++ b/20211025/structs-12.c @@ -0,0 +1,42 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; + print_date (d); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-13.c b/20211025/structs-13.c new file mode 100644 index 0000000000000000000000000000000000000000..3f98442eddcb914f5f627995fa6625c40ee69c09 --- /dev/null +++ b/20211025/structs-13.c @@ -0,0 +1,40 @@ +#include <stdio.h> + +struct date +{ + char day, month; + int year; +}; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-14.c b/20211025/structs-14.c new file mode 100644 index 0000000000000000000000000000000000000000..2dafc78b856dfcce7487dfa54e2daaa27f646ca0 --- /dev/null +++ b/20211025/structs-14.c @@ -0,0 +1,40 @@ +#include <stdio.h> + +struct date +{ + char day, month; + int year; +}; + +void set_date (struct date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void print_date (struct date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +void scan_date (struct date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; +} + +int main (void) +{ + struct date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-15.c b/20211025/structs-15.c new file mode 100644 index 0000000000000000000000000000000000000000..c7317c6d20f9895a40e23258dc0f1bbeab57c331 --- /dev/null +++ b/20211025/structs-15.c @@ -0,0 +1,40 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + print_date (d); + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &d->month); + print_date (d); + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &d->day); + print_date (d); +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + scan_date (&today); + return 0; +} diff --git a/20211025/structs-16.c b/20211025/structs-16.c new file mode 100644 index 0000000000000000000000000000000000000000..2bd21f6fd41cbaf85469267b1e6e8b984a40029a --- /dev/null +++ b/20211025/structs-16.c @@ -0,0 +1,40 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void scan_date (date *d) +{ + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &d->day); + print_date (d); + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &d->month); + print_date (d); + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + print_date (d); +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + scan_date (&today); + return 0; +} diff --git a/20211025/structs-1a.c b/20211025/structs-1a.c new file mode 100644 index 0000000000000000000000000000000000000000..7eaba7796887e8174668ae6371495507cf8eda5c --- /dev/null +++ b/20211025/structs-1a.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { ' ' - 7, '\n', 2021 }; + printf ("%d.%d.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-1b.c b/20211025/structs-1b.c new file mode 100644 index 0000000000000000000000000000000000000000..14997410621c5ad83bfad29fd72361b1a6f1e218 --- /dev/null +++ b/20211025/structs-1b.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { '1', '2', 2021 }; + printf ("%d.%d.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-1c.c b/20211025/structs-1c.c new file mode 100644 index 0000000000000000000000000000000000000000..eaa8a3d8846797354ea58ee37e1700606097f370 --- /dev/null +++ b/20211025/structs-1c.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { 25, 10, 2021 }; + printf ("%c.%c.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-1d.c b/20211025/structs-1d.c new file mode 100644 index 0000000000000000000000000000000000000000..9e35a255edbac4339112f5b30df2bedc415b6b97 --- /dev/null +++ b/20211025/structs-1d.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { 25, 10, 2021 }; + printf ("%c.%c.%c\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-1e.c b/20211025/structs-1e.c new file mode 100644 index 0000000000000000000000000000000000000000..cd7a312ae9572b38e683fbcf3c92300f23a91bc4 --- /dev/null +++ b/20211025/structs-1e.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { 25, 10, 2090 }; + printf ("%c.%c.%c\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-2.c b/20211025/structs-2.c new file mode 100644 index 0000000000000000000000000000000000000000..1a8ba6ad69333562c7aadc282d57e37903f07f56 --- /dev/null +++ b/20211025/structs-2.c @@ -0,0 +1,23 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + (*d).day = 18; + (*d).month = 10; + (*d).year = 2021; +} + +int main (void) +{ + date today; + set_date (&today); + printf ("%d.%d.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20211025/structs-3.c b/20211025/structs-3.c new file mode 100644 index 0000000000000000000000000000000000000000..1c051463ac6f958add35ea6096e86d93c09dcbf3 --- /dev/null +++ b/20211025/structs-3.c @@ -0,0 +1,5 @@ +#include <stdio.h> +typedef struct { char day, month; int year; } date; void set_date (date *d) { +(*d).day = 18; (*d).month = 10; (*d).year = 2021; } int main (void) { date +today; set_date (&today); printf ("%d.%d.%d\n", today.day, today.month, +today.year); return 0; } diff --git a/20211025/structs-4.c b/20211025/structs-4.c new file mode 100644 index 0000000000000000000000000000000000000000..5d41fe592b6838e3cb940f53689b3bc478437a14 --- /dev/null +++ b/20211025/structs-4.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} date; + +void set_date (date *d) +{ + (*d).day = 18; + (*d).month = 10; + (*d).year = 2021; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", (*d).day, (*d).month, (*d).year); +} + +int main (void) +{ + date today; + set_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-5.c b/20211025/structs-5.c new file mode 100644 index 0000000000000000000000000000000000000000..1cdf06f81a33b1296b15f64dc1865f8f3082ca12 --- /dev/null +++ b/20211025/structs-5.c @@ -0,0 +1,28 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + set_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-6.c b/20211025/structs-6.c new file mode 100644 index 0000000000000000000000000000000000000000..19c599e4f6304aeace3ba95ab4b831eddd19457b --- /dev/null +++ b/20211025/structs-6.c @@ -0,0 +1,38 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &d->month); + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &d->day); +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-7.c b/20211025/structs-7.c new file mode 100644 index 0000000000000000000000000000000000000000..608af06420e4540d5d0feab5d08b7a6218673005 --- /dev/null +++ b/20211025/structs-7.c @@ -0,0 +1,38 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%hhd", &d->month); + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%hhd", &d->day); +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-8.c b/20211025/structs-8.c new file mode 100644 index 0000000000000000000000000000000000000000..cb07d7656f0934a06da5d6a45c6570481bf9fb8c --- /dev/null +++ b/20211025/structs-8.c @@ -0,0 +1,41 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%d", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +} diff --git a/20211025/structs-9.c b/20211025/structs-9.c new file mode 100644 index 0000000000000000000000000000000000000000..65ba4e176795331c477dfa9b4004c5edfaf1b523 --- /dev/null +++ b/20211025/structs-9.c @@ -0,0 +1,41 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 18; + d->month = 10; + d->year = 2021; +} + +void scan_date (date *d) +{ + printf ("Bitte das Jahr eingeben (vierstellig): "); + scanf ("%hhd", &d->year); + int tmp; + printf ("Bitte den Monat eingeben (1 bis 12): "); + scanf ("%d", &tmp); + d->month = tmp; + printf ("Bitte den Tag eingeben (1 bis 31): "); + scanf ("%d", &tmp); + d->day = tmp; +} + +void print_date (date *d) +{ + printf ("%d.%d.%d\n", d->day, d->month, d->year); +} + +int main (void) +{ + date today; + scan_date (&today); + print_date (&today); + return 0; +}