diff --git a/20201105/hp-uebung-20201105.pdf b/20201105/hp-uebung-20201105.pdf index 2281b745a2a15e4efacaa6d95e4a5a372a64bdcb..9fc02ee3495f5fa32eda3f023b6f448333f3ecc3 100644 Binary files a/20201105/hp-uebung-20201105.pdf and b/20201105/hp-uebung-20201105.pdf differ diff --git a/20201105/hp-uebung-20201105.tex b/20201105/hp-uebung-20201105.tex index 9c7a0e5d1f0841e9acc6f38230809f46bbf25b4e..00c6d2be5cb44c969c338b69263b02aa69ba1a05 100644 --- a/20201105/hp-uebung-20201105.tex +++ b/20201105/hp-uebung-20201105.tex @@ -68,7 +68,8 @@ \begin{lstlisting}[style=cmd] gcc -Wall -O hello.c -o hello ./hello - gcc -Wall -O hello-gtk.c $(pkg-config --cflags --libs gtk+-3.0) -o hello-gtk + gcc -Wall -O $(pkg-config --cflags gtk+-3.0) hello-gtk.c \ + $(pkg-config --libs gtk+-3.0) -o hello-gtk ./hello-gtk \end{lstlisting} diff --git a/20201112/hp-2020ws-p1.pdf b/20201112/hp-2020ws-p1.pdf index ce2f5d77fc2327b6da5d78d1ff8ee977a480907d..21817a9946f935f48a046ef3cc2c1f2025dc9875 100644 Binary files a/20201112/hp-2020ws-p1.pdf and b/20201112/hp-2020ws-p1.pdf differ diff --git a/20201112/hp-2020ws-p1.tex b/20201112/hp-2020ws-p1.tex index 82313e316d1a27d3e559727674ea91106c31ad66..7eff7a252852eaa3e862ed2e50d0c571ca609bc2 100644 --- a/20201112/hp-2020ws-p1.tex +++ b/20201112/hp-2020ws-p1.tex @@ -136,13 +136,22 @@ beruht die Sicherheit der RSA-Verschlüsselung.) \textbf{Hinweis 1:} - Wenn Sie ein Programm per Kommandozeile mit \lstinline[style=cmd]{time ./programm} starten, - wird Ihnen angezeigt, wieviel Rechenzeit das Programm benötigt hat. - Die drei angezeigten Werte stehen hierbei für die - tatsächlich verstrichene Gesamtzeit (\lstinline[style=terminal]{real}), - für die mit Rechnen verbrachte Zeit (\lstinline[style=terminal]{user}) - und für die mit Systemaufrufen (z.\,B.\ Ein- und Ausgabe) - verbrachte Zeit (\lstinline[style=terminal]{sys}). +% Wenn Sie ein Programm per Kommandozeile mit \lstinline[style=cmd]{time ./programm} starten, +% wird Ihnen angezeigt, wieviel Rechenzeit das Programm benötigt hat. +% Die drei angezeigten Werte stehen hierbei für die +% tatsächlich verstrichene Gesamtzeit (\lstinline[style=terminal]{real}), +% für die mit Rechnen verbrachte Zeit (\lstinline[style=terminal]{user}) +% und für die mit Systemaufrufen (z.\,B.\ Ein- und Ausgabe) +% verbrachte Zeit (\lstinline[style=terminal]{sys}). + Ein einfacher Weg, die von Ihrem Programm benötigte Rechenzeit zu messen, + ist die Verwendung der Funktion \lstinline{clock()}. + Diese gibt zurück, wieviel Rechenzeit seit Programmstart aufgewendet wurde. + Der Typ dieses Rückgabewerts ist ein ganzzahliger Typ, \lstinline{clock_t}, + mit dem man rechnen und den man mit \lstinline{%ld} ausgeben kann. + Pro Sekunde wächst der Zähler um \lstinline{CLOCKS_PER_SEC} Einheiten. + Typischerweise hat \lstinline{CLOCKS_PER_SEC} den Wert \lstinline{1000000} + oder \lstinline{1000}, die Zeiteinheit ist also eine Mikrosekunde + bzw.\ eine Millisekunde. \textbf{Hinweis 2:} Die mit der o.\,a.\ Methode meßbaren Zeiten sind eigentlich zu ungenau, @@ -172,7 +181,7 @@ \setlength{\leftskip}{3cm} - Stand: 12.\ November 2020 + Stand: 26.\ November 2020 % Soweit nicht anders angegeben:\\ Copyright \copyright\ 2014, 2015, 2016, 2017, 2018, 2019, 2020\quad Peter Gerwinski\\ diff --git "a/20201126/!\"\302\247$%&/().txt" "b/20201126/!\"\302\247$%&/().txt" new file mode 100644 index 0000000000000000000000000000000000000000..af5626b4a114abcb82d63db7c8082c3c4756e51b --- /dev/null +++ "b/20201126/!\"\302\247$%&/().txt" @@ -0,0 +1 @@ +Hello, world! diff --git a/20201126/case-convert-1.c b/20201126/case-convert-1.c new file mode 100644 index 0000000000000000000000000000000000000000..014847ef707d757d7a7a3aec8da33bc5e215a987 --- /dev/null +++ b/20201126/case-convert-1.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char ch = 'f'; + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/case-convert-2.c b/20201126/case-convert-2.c new file mode 100644 index 0000000000000000000000000000000000000000..3369266d66046b658726e9df95e965c28dd19770 --- /dev/null +++ b/20201126/case-convert-2.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char ch = 'f'; + ch -= 32; + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/case-convert-3.c b/20201126/case-convert-3.c new file mode 100644 index 0000000000000000000000000000000000000000..67666849149fc37220cc793c4f266b2a05ea2983 --- /dev/null +++ b/20201126/case-convert-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char ch = 'f'; + ch = ch - 'f' + 'F'; + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/case-convert-4.c b/20201126/case-convert-4.c new file mode 100644 index 0000000000000000000000000000000000000000..06648d1f097adfed6bd3cc7246b59f3f958a6a70 --- /dev/null +++ b/20201126/case-convert-4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char ch = 'f'; + ch += 'F' - 'f'; + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/case-convert-5.c b/20201126/case-convert-5.c new file mode 100644 index 0000000000000000000000000000000000000000..5718dda862fea32003090f38d446c3f3a74bdc93 --- /dev/null +++ b/20201126/case-convert-5.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char ch = 'f'; + ch += 'A' - 'a'; + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/case-convert-6.c b/20201126/case-convert-6.c new file mode 100644 index 0000000000000000000000000000000000000000..1f7960abb162cb218ad44643cacbacc09e250e17 --- /dev/null +++ b/20201126/case-convert-6.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char ch = 'G'; + ch += 'a' - 'A'; + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/case-convert-7.c b/20201126/case-convert-7.c new file mode 100644 index 0000000000000000000000000000000000000000..0133886c5c7bd30abb6ba9f7e0aed96dee765b2f --- /dev/null +++ b/20201126/case-convert-7.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <ctype.h> + +int main (void) +{ + char ch = 'G'; + ch = tolower (ch); + printf ("%c\n", ch); + return 0; +} diff --git a/20201126/fhello-1.c b/20201126/fhello-1.c new file mode 100644 index 0000000000000000000000000000000000000000..6548d9c81c73a7f3da8b1b2e62290bc8029d11f0 --- /dev/null +++ b/20201126/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/20201126/fhello-10.c b/20201126/fhello-10.c new file mode 100644 index 0000000000000000000000000000000000000000..78247d9705598987ddb185d5fc216fe4bacf6fea --- /dev/null +++ b/20201126/fhello-10.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + FILE *f = fopen ("/bin/bash", "w"); + if (!f) + error (errno, errno, "cannot open file"); + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20201126/fhello-2.c b/20201126/fhello-2.c new file mode 100644 index 0000000000000000000000000000000000000000..2acae5f3218fef4441eca339682c0d8076e4e18d --- /dev/null +++ b/20201126/fhello-2.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + FILE *f = fopen ("fhello.txt", "a"); /* "a" = "append", "w" = "(over)write" */ + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20201126/fhello-3.c b/20201126/fhello-3.c new file mode 100644 index 0000000000000000000000000000000000000000..50afa600ce12073f7646a0548807b6472bc3b11e --- /dev/null +++ b/20201126/fhello-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + FILE *f = fopen ("!\"§$%&/().txt", "w"); + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20201126/fhello-4.c b/20201126/fhello-4.c new file mode 100644 index 0000000000000000000000000000000000000000..7bda3500fb3e652126b90e8ba3daea29a7dce026 --- /dev/null +++ b/20201126/fhello-4.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main (void) +{ + FILE *f = fopen ("!\"§$%&/().txt", "w"); + if (f != NULL) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + return 0; +} diff --git a/20201126/fhello-5.c b/20201126/fhello-5.c new file mode 100644 index 0000000000000000000000000000000000000000..0445ee2006464b73ab44f95dce0b60324391834c --- /dev/null +++ b/20201126/fhello-5.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main (void) +{ + FILE *f = fopen ("!\"§$%&/().txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + return 0; +} diff --git a/20201126/fhello-6.c b/20201126/fhello-6.c new file mode 100644 index 0000000000000000000000000000000000000000..a479c4694d2d370c5182d993c40ee8b4e73c4eb6 --- /dev/null +++ b/20201126/fhello-6.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <errno.h> + +int main (void) +{ + FILE *f = fopen ("!\"§$%&/().txt", "w"); + if (f) + { + fprintf (f, "Hello, world!\n"); + fclose (f); + } + else + fprintf (stderr, "error #%d\n", errno); + return 0; +} diff --git a/20201126/fhello-7.c b/20201126/fhello-7.c new file mode 100644 index 0000000000000000000000000000000000000000..96a6610279c9a8bb6422aad12e96a33759fe6cd5 --- /dev/null +++ b/20201126/fhello-7.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <errno.h> +#include <string.h> + +int main (void) +{ + FILE *f = fopen ("!\"§$%&/().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/20201126/fhello-8.c b/20201126/fhello-8.c new file mode 100644 index 0000000000000000000000000000000000000000..dc2ae6dea521671443cec60ded691ac360bc7a36 --- /dev/null +++ b/20201126/fhello-8.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + FILE *f = fopen ("!\"§$%&/().txt", "w"); + if (f == NULL) + error (1, errno, "cannot open file"); + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20201126/fhello-9.c b/20201126/fhello-9.c new file mode 100644 index 0000000000000000000000000000000000000000..eaf23c4c77267d20d0b97fe46fa552b748df2c33 --- /dev/null +++ b/20201126/fhello-9.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <errno.h> +#include <error.h> + +int main (void) +{ + FILE *f = fopen ("/bin/bash", "w"); + if (!f) + error (1, errno, "cannot open file"); + fprintf (f, "Hello, world!\n"); + fclose (f); + return 0; +} diff --git a/20201126/fhello.txt b/20201126/fhello.txt new file mode 100644 index 0000000000000000000000000000000000000000..95e75d98dbaf42c1efc9be0405e079f97aa24888 --- /dev/null +++ b/20201126/fhello.txt @@ -0,0 +1,2 @@ +Hello, world! +Hello, world! diff --git a/20201126/hp-20201126.pdf b/20201126/hp-20201126.pdf index 24f5c277e9a3246b4bbcf6702ba3ccdbab0f756c..2959fd2fd51e46a31144dde6e7d15453ce89b729 100644 Binary files a/20201126/hp-20201126.pdf and b/20201126/hp-20201126.pdf differ diff --git a/20201126/hp-20201126.tex b/20201126/hp-20201126.tex index 1a6e9d005a3b3d34ec632abe027bbeaac2aa6f01..4c7a8e88b1e7826dc63f339b4199c9346090b1ae 100644 --- a/20201126/hp-20201126.tex +++ b/20201126/hp-20201126.tex @@ -138,7 +138,7 @@ Ein Zeiger zeigt auf eine Variable\only<2->{ und deren Nachbarn}. - \bigskip +% \bigskip \pause \pause @@ -458,36 +458,31 @@ \begin{itemize} \item - Welchen Zahlenwert hat \lstinline{'*'} im Zeichensatz (normalerweise: ASCII)?\\ - Welches Zeichen entspricht dem Zahlenwert \lstinline{71}? + Welchen Zahlenwert hat \lstinline{'*'} im Zeichensatz? \smallskip \begin{lstlisting}[gobble=8] printf ("%d\n", '*'); - printf ("%c\n", 71); \end{lstlisting} - \medskip - \item - Ist \lstinline{char ch} ein Großbuchstabe? \smallskip + (normalerweise: ASCII) + \medskip + \item + Ist \lstinline{char ch} ein Großbuchstabe?\\[-\smallskipamount] \begin{lstlisting}[gobble=8] if (ch >= 'A' && ch <= 'Z') ... \end{lstlisting} - \smallskip + \medskip \item - Groß- in Kleinbuchstaben umwandeln - - \smallskip - + Groß- in Kleinbuchstaben umwandeln\\[-\smallskipamount] \begin{lstlisting}[gobble=8] ch += 'a' - 'A'; \end{lstlisting} \end{itemize} - \vspace*{-1cm} \end{frame} \subsection{Strukturen} @@ -507,7 +502,7 @@ int main (void) { - date today = { 24, 10, 2019 }; + date today = { 16, 11, 2020 }; printf ("%d.%d.%d\n", today.day, today.month, today.year); return 0; } @@ -531,9 +526,9 @@ void set_date (date *d) { - (*d).day = 24; - (*d).month = 10; - (*d).year = 2019; + (*d).day = 26; + (*d).month = 11; + (*d).year = 2020; }¿ \end{lstlisting} \end{minipage}% @@ -568,9 +563,9 @@ void set_date (date *d) { - d->day = 24; - d->month = 10; - d->year = 2019; + d->day = 26; + d->month = 11; + d->year = 2020; }¿ \end{lstlisting} \end{minipage}% diff --git a/20201126/printf-shell-1.txt b/20201126/printf-shell-1.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce393366b481a5c51a936c9b24fe25225c497787 --- /dev/null +++ b/20201126/printf-shell-1.txt @@ -0,0 +1,8 @@ +cassini/home/peter/bo/2020ws/hp/20201126> printf "%d\n" "*" +bash: printf: *: Ungültige Zahl. +0 +cassini/home/peter/bo/2020ws/hp/20201126> printf "%d\n" "'*'" +42 +cassini/home/peter/bo/2020ws/hp/20201126> printf "%c\n" "71" +7 +cassini/home/peter/bo/2020ws/hp/20201126> diff --git a/20201126/strings-1.c b/20201126/strings-1.c new file mode 100644 index 0000000000000000000000000000000000000000..81bc3cda8affb6268786ac989dd2907d9a84783a --- /dev/null +++ b/20201126/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/20201126/strings-10.c b/20201126/strings-10.c new file mode 100644 index 0000000000000000000000000000000000000000..4eeff0a580144625c15a6891d4286cf3da8d5f77 --- /dev/null +++ b/20201126/strings-10.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello!\n"; + printf ("%s", hello); + hello[2] = 'a'; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-11.c b/20201126/strings-11.c new file mode 100644 index 0000000000000000000000000000000000000000..10e25acce870c66d065dc0015eeba501ad86e0a7 --- /dev/null +++ b/20201126/strings-11.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/20201126/strings-12.c b/20201126/strings-12.c new file mode 100644 index 0000000000000000000000000000000000000000..ce49cd0f83ac1e365fd65bb6062aeb9232f18ed3 --- /dev/null +++ b/20201126/strings-12.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello!\n"; + printf ("%s", hello); + hello[1] = 97; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-13.c b/20201126/strings-13.c new file mode 100644 index 0000000000000000000000000000000000000000..dc6b7ca9a467d92f6862d273006873c26bcf122a --- /dev/null +++ b/20201126/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/20201126/strings-14.c b/20201126/strings-14.c new file mode 100644 index 0000000000000000000000000000000000000000..763459bc896426c4814d752938c2d5bbd00dca9a --- /dev/null +++ b/20201126/strings-14.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello!\n"; + printf ("%s", hello); + hello = "Hallo?\n"; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-15.c b/20201126/strings-15.c new file mode 100644 index 0000000000000000000000000000000000000000..35197e386606fdf120f375fcf078be814ce7b633 --- /dev/null +++ b/20201126/strings-15.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello!\n"; + printf ("%s", hello); + hello = "Hallo, Welt!\n"; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-16.c b/20201126/strings-16.c new file mode 100644 index 0000000000000000000000000000000000000000..64abcdc7574cfbe0424643a2c4076fdd448f53fd --- /dev/null +++ b/20201126/strings-16.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello!\n"; + printf ("%s", hello); + hello = "Hallo, Welt!\n"; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-17.c b/20201126/strings-17.c new file mode 100644 index 0000000000000000000000000000000000000000..b0d9dcebb6acd1df56fc3b1314a6f6d8cf7a7a04 --- /dev/null +++ b/20201126/strings-17.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char hello[] = "Hello!\n"; + printf ("%s", hello); + strcpy (hello, "Hallo, Welt!\n"); /* Achtung: Dies kann einen Absturz bewirken! */ + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-2.c b/20201126/strings-2.c new file mode 100644 index 0000000000000000000000000000000000000000..4df32974a15ef2752512cc8b9889381b5a0917cd --- /dev/null +++ b/20201126/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/20201126/strings-3.c b/20201126/strings-3.c new file mode 100644 index 0000000000000000000000000000000000000000..8da904190d58e16b20d84e19a41e639893831f5e --- /dev/null +++ b/20201126/strings-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10 }; + for (char *p = hello; *p; p++) + printf ("%c", *p); + return 0; +} diff --git a/20201126/strings-4.c b/20201126/strings-4.c new file mode 100644 index 0000000000000000000000000000000000000000..5c36db92dac8129b66d1f0ff6b709534b9e1bdb3 --- /dev/null +++ b/20201126/strings-4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 }; + for (char *p = hello; *p; p++) + printf ("%c", *p); + return 0; +} diff --git a/20201126/strings-5.c b/20201126/strings-5.c new file mode 100644 index 0000000000000000000000000000000000000000..74f11c34440c4ed87b886ef9aad8c9a39cb70a33 --- /dev/null +++ b/20201126/strings-5.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 }; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-6.c b/20201126/strings-6.c new file mode 100644 index 0000000000000000000000000000000000000000..75c2a1cc5802891944f08a18056bb88194960fac --- /dev/null +++ b/20201126/strings-6.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = { 51, 50, 49, 48, 10, 0 }; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-7.c b/20201126/strings-7.c new file mode 100644 index 0000000000000000000000000000000000000000..68227c25325d9699430cacc3d071c5dad629fb40 --- /dev/null +++ b/20201126/strings-7.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + printf ("%s", hello); + return 0; +} diff --git a/20201126/strings-8.c b/20201126/strings-8.c new file mode 100644 index 0000000000000000000000000000000000000000..c75e8485434dd0f3578ad93e7c574f466424e544 --- /dev/null +++ b/20201126/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/20201126/strings-9.c b/20201126/strings-9.c new file mode 100644 index 0000000000000000000000000000000000000000..5db41cf82ce518086b515eadca849ee76d87dc02 --- /dev/null +++ b/20201126/strings-9.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello!\n"; + printf ("%s", hello); + hello[2] = "a"; + printf ("%s", hello); + return 0; +} diff --git a/20201126/structs-0.c b/20201126/structs-0.c new file mode 100644 index 0000000000000000000000000000000000000000..c597fc0612ca99a9d3d258310326bbee79f4f258 --- /dev/null +++ b/20201126/structs-0.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +char day, month; +int year; + +int main (void) +{ + day = 26; + month = 11; + year = 2020; + printf ("%d.%d.%d\n", day, month, year); + return 0; +} diff --git a/20201126/structs-1.c b/20201126/structs-1.c new file mode 100644 index 0000000000000000000000000000000000000000..1d71fbad0842877465d396b725b1f9626e0d9eb4 --- /dev/null +++ b/20201126/structs-1.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +int main (void) +{ + date today = { 26, 11, 2020 }; + printf ("%d.%d.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20201126/structs-2.c b/20201126/structs-2.c new file mode 100644 index 0000000000000000000000000000000000000000..e9d0986ccdf4a7106e59c0ee30eb1bfcd779e255 --- /dev/null +++ b/20201126/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 = 26; + (*d).month = 11; + (*d).year = 2020; +} + +int main (void) +{ + date today; + set_date (&today); + printf ("%d.%d.%d\n", today.day, today.month, today.year); + return 0; +} diff --git a/20201126/structs-3.c b/20201126/structs-3.c new file mode 100644 index 0000000000000000000000000000000000000000..6ed3133cc2097f3b7682588d2cef1b7aafeed692 --- /dev/null +++ b/20201126/structs-3.c @@ -0,0 +1,28 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + (*d).day = 26; + (*d).month = 11; + (*d).year = 2020; +} + +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/20201126/structs-4.c b/20201126/structs-4.c new file mode 100644 index 0000000000000000000000000000000000000000..390ce938ef8fd579b860b96303264b7303e67123 --- /dev/null +++ b/20201126/structs-4.c @@ -0,0 +1,28 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; +} +date; + +void set_date (date *d) +{ + d->day = 26; + d->month = 11; + d->year = 2020; +} + +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/20201126/structs-5.c b/20201126/structs-5.c new file mode 100644 index 0000000000000000000000000000000000000000..d48a32b38c32a57265042e3029aee6bd14467dae --- /dev/null +++ b/20201126/structs-5.c @@ -0,0 +1,30 @@ +#include <stdio.h> + +typedef struct +{ + char day, month; + int year; + char *day_of_week; +} +date; + +void set_date (date *d) +{ + d->day = 26; + d->month = 11; + d->year = 2020; + d->day_of_week = "Thu"; +} + +void print_date (date *d) +{ + printf ("%s, %d.%d.%d\n", d->day_of_week, d->day, d->month, d->year); +} + +int main (void) +{ + date today; + set_date (&today); + print_date (&today); + return 0; +} diff --git a/20201126/test-1.txt b/20201126/test-1.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa4dca97b969d32af064e9bf480c1f861caea227 --- /dev/null +++ b/20201126/test-1.txt @@ -0,0 +1,10 @@ +cassini/home/peter/bo/2020ws/hp/20201126> cat +Hallo? +Hallo? +Hallo. +Hallo. +cassini/home/peter/bo/2020ws/hp/20201126> cat > test.txt +Dies ist ein Test. +cassini/home/peter/bo/2020ws/hp/20201126> cat test.txt +Dies ist ein Test. +cassini/home/peter/bo/2020ws/hp/20201126> diff --git a/20201126/test.txt b/20201126/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..d7e5cff47f0303c2d892d3e790e00552759b639c --- /dev/null +++ b/20201126/test.txt @@ -0,0 +1 @@ +Dies ist ein Test.