diff --git a/20231019/strings-07a.c b/20231019/strings-07a.c new file mode 100644 index 0000000000000000000000000000000000000000..3fa3628578baf33dc75039022b6f5983bb8c6ade --- /dev/null +++ b/20231019/strings-07a.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + printf ("%s\n", hello - 7); + printf ("%zd\n", strlen (hello - 7)); + + return 0; + + hello[5] = 0; + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + return 0; +} diff --git a/20231019/strings-07b.c b/20231019/strings-07b.c new file mode 100644 index 0000000000000000000000000000000000000000..a1fa8d7d33676c15902ff076c7613b58efcab450 --- /dev/null +++ b/20231019/strings-07b.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + printf ("%s\n", hello - 1); + printf ("%zd\n", strlen (hello - 1)); + + return 0; + + hello[5] = 0; + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + return 0; +} diff --git a/20231019/strings-07c.c b/20231019/strings-07c.c new file mode 100644 index 0000000000000000000000000000000000000000..a1fa8d7d33676c15902ff076c7613b58efcab450 --- /dev/null +++ b/20231019/strings-07c.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + printf ("%s\n", hello - 1); + printf ("%zd\n", strlen (hello - 1)); + + return 0; + + hello[5] = 0; + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + return 0; +} diff --git a/20231019/strings-07d.c b/20231019/strings-07d.c new file mode 100644 index 0000000000000000000000000000000000000000..ba7d83c1e76e6a7f90ed96b871dd91203be4ab92 --- /dev/null +++ b/20231019/strings-07d.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char hello[] = "Hello, world!\n"; + + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + printf ("%s\n", hello + 17); + printf ("%zd\n", strlen (hello + 17)); + + return 0; + + hello[5] = 0; + printf ("%s\n", hello); + printf ("%zd\n", strlen (hello)); + + return 0; +} diff --git a/20231026/answer.c b/20231026/answer.c new file mode 100644 index 0000000000000000000000000000000000000000..65a1dc248becb3157f2a226fc7b30df2ffb82e00 --- /dev/null +++ b/20231026/answer.c @@ -0,0 +1,6 @@ +#include "answer.h" + +int answer (void) +{ + return 23; +} diff --git a/20231026/answer.h b/20231026/answer.h new file mode 100644 index 0000000000000000000000000000000000000000..b6777e8210983d315b3ac3424a61bd9c9f0437b1 --- /dev/null +++ b/20231026/answer.h @@ -0,0 +1 @@ +extern int answer (void); diff --git a/20231026/gtk-01.c b/20231026/gtk-01.c index 6e4cf8a819c88092ecb039ad9221611f5577d925..2cd0d601dee2293fdc361126ca08d208d7cdc1b9 100644 --- a/20231026/gtk-01.c +++ b/20231026/gtk-01.c @@ -9,7 +9,7 @@ static void activate (GtkApplication *app, gpointer user_data) int main (int argc, char **argv) { - GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-01", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); int status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); diff --git a/20231026/gtk-02.c b/20231026/gtk-02.c index 507acdf0cd745527e56defbded7c6c70bfe642e3..1ab3c19ea31e2c4a7960937bb97509bb0ad9ecdd 100644 --- a/20231026/gtk-02.c +++ b/20231026/gtk-02.c @@ -1,4 +1,5 @@ #include <gtk/gtk.h> +#include <stdio.h> static void hello (GtkWidget *this, gpointer user_data) { @@ -18,7 +19,7 @@ static void activate (GtkApplication *app, gpointer user_data) int main (int argc, char **argv) { - GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-02", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); int status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); diff --git a/20231026/hello-01.c b/20231026/hello-01.c new file mode 100644 index 0000000000000000000000000000000000000000..b19d80e9bd0bd7c5ed8f54b20c6a50d9166f03ac --- /dev/null +++ b/20231026/hello-01.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (void) +{ + printf ("Hello, world!\n"); + return 0; +} diff --git a/20231026/hello-02.c b/20231026/hello-02.c new file mode 100644 index 0000000000000000000000000000000000000000..304452b8c501faf03fbd0afaa267e6ef0172807e --- /dev/null +++ b/20231026/hello-02.c @@ -0,0 +1,7 @@ +extern int printf (const char *__restrict __format, ...); + +int main (void) +{ + printf ("Hello, world!\n"); + return 0; +} diff --git a/20231026/higher-math-01.c b/20231026/higher-math-01.c new file mode 100644 index 0000000000000000000000000000000000000000..87819084490cdc730ac84ef7d395a5a88fd59ee4 --- /dev/null +++ b/20231026/higher-math-01.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#define NINE 9 +#define SIX 6 + +int main (void) +{ + printf ("nine times six = %d\n", NINE * SIX); + return 0; +} diff --git a/20231026/higher-math-02.c b/20231026/higher-math-02.c new file mode 100644 index 0000000000000000000000000000000000000000..04a8ae4aa785612e005d966c25b1dc5196002e25 --- /dev/null +++ b/20231026/higher-math-02.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#define NINE 1 + 8 +#define SIX 5 + 1 + +int main (void) +{ + printf ("nine times six = %d\n", NINE * SIX); + return 0; +} diff --git a/20231026/higher-math-03.c b/20231026/higher-math-03.c new file mode 100644 index 0000000000000000000000000000000000000000..14518739b38487f6b51e913da24687fdc4c03732 --- /dev/null +++ b/20231026/higher-math-03.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#define NINE (1 + 8) +#define SIX (5 + 1) + +int main (void) +{ + printf ("nine times six = %d\n", NINE * SIX); + return 0; +} diff --git a/20231026/higher-math-04.c b/20231026/higher-math-04.c new file mode 100644 index 0000000000000000000000000000000000000000..e2390dc29317d85e914b18628deb4beb61808fee --- /dev/null +++ b/20231026/higher-math-04.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#define NINE (1 + 8) +#define SIX (5 + 1)); + +int main (void) +{ + printf ("nine times six = %d\n", NINE * SIX + return 0; +} diff --git a/20231026/higher-math-05.c b/20231026/higher-math-05.c new file mode 100644 index 0000000000000000000000000000000000000000..8ce485e1667a7f22cf2accbda12cc26139a747b7 --- /dev/null +++ b/20231026/higher-math-05.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#define NINE (1 + 8 +#define SIX (5 + 1)); + +int main (void) +{ + printf ("nine times six = %d\n", NINE) * SIX + return 0; +} diff --git a/20231026/hp-20231026.pdf b/20231026/hp-20231026.pdf index ca79ca5a6b4a3df11a0a9db2f0f526ff41738ac1..f77755cdbeaa1b602b45bfd1ce950a4a3bbac722 100644 Binary files a/20231026/hp-20231026.pdf and b/20231026/hp-20231026.pdf differ diff --git a/20231026/hp-20231026.tex b/20231026/hp-20231026.tex index 6fb14dbf14f7ded25d0e9c45b18e8bf2403c0730..a24cc997f615df00b9f902ff93e19068f7dc5134 100644 --- a/20231026/hp-20231026.tex +++ b/20231026/hp-20231026.tex @@ -514,7 +514,7 @@ int main (void) { - date today = { 17, 10, 2022 }; + date today = { 26, 10, 2023 }; printf ("%d.%d.%d\n", today.day, today.month, today.year); return 0; } @@ -538,9 +538,9 @@ void set_date (date *d) { - (*d).day = 17; + (*d).day = 26; (*d).month = 10; - (*d).year = 2022; + (*d).year = 2023; }¿ \end{lstlisting} \end{minipage}% @@ -575,9 +575,9 @@ void set_date (date *d) { - d->day = 17; + d->day = 26; d->month = 10; - d->year = 2022; + d->year = 2023; }¿ \end{lstlisting} \end{minipage}% @@ -1050,7 +1050,7 @@ \pause \smallskip \item - Mit \lstinline[style=cmd]{pkg-config --cflags --libs} erfährt man,\\ + Mit \lstinline[style=cmd]{pkg-config --cflags --libs gtk4} erfährt man,\\ welche Optionen und Bibliotheken man an \lstinline[style=cmd]{gcc} übergeben muß\alt<4->{.}{:} \pause diff --git a/20231026/philosophy.c b/20231026/philosophy.c new file mode 100644 index 0000000000000000000000000000000000000000..e9f508a501d9ec66d02e0636a9f6c71f2c7a8594 --- /dev/null +++ b/20231026/philosophy.c @@ -0,0 +1,8 @@ +#include <stdio.h> +#include "answer.h" + +int main (void) +{ + printf ("The answer is %d.\n", answer ()); + return 0; +} diff --git a/20231026/string-ops-01.c b/20231026/string-ops-01.c new file mode 100644 index 0000000000000000000000000000000000000000..341425480d63a35be17fcd7d17b5ca7ac8adb574 --- /dev/null +++ b/20231026/string-ops-01.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *anton = "Anton"; + char *zacharias = "Zacharias"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + return 0; + + char buffer[100] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + + return 0; +} diff --git a/20231026/string-ops-02.c b/20231026/string-ops-02.c new file mode 100644 index 0000000000000000000000000000000000000000..7ee59d55ca152cefb831839e364de20c71987506 --- /dev/null +++ b/20231026/string-ops-02.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *anton = "Anton"; + char *zacharias = "Zacharias"; + + printf ("%d\n", anton < zacharias); + printf ("%d\n", zacharias < anton); + printf ("%d\n", anton == anton); + + return 0; + + char buffer[100] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + + return 0; +} diff --git a/20231026/string-ops-02.s b/20231026/string-ops-02.s new file mode 100644 index 0000000000000000000000000000000000000000..fd7f407a4fa1e6e0b6ca2eb82e9a63578dd3b710 --- /dev/null +++ b/20231026/string-ops-02.s @@ -0,0 +1,48 @@ + .file "string-ops-02.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Anton" +.LC1: + .string "Zacharias" +.LC2: + .string "%d\n" + .text + .globl main + .type main, @function +main: +.LFB11: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + leaq .LC0(%rip), %rdx + leaq .LC1(%rip), %rax + cmpq %rax, %rdx + setb %sil + movzbl %sil, %esi + leaq .LC2(%rip), %rdi + movl $0, %eax + call printf@PLT + leaq .LC1(%rip), %rdx + leaq .LC0(%rip), %rax + cmpq %rax, %rdx + setb %sil + movzbl %sil, %esi + leaq .LC2(%rip), %rbx + movq %rbx, %rdi + movl $0, %eax + call printf@PLT + movl $1, %esi + movq %rbx, %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20231026/string-ops-03.c b/20231026/string-ops-03.c new file mode 100644 index 0000000000000000000000000000000000000000..dbae824c1d9c02323388a8d7894d9adde13d8298 --- /dev/null +++ b/20231026/string-ops-03.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacharias"; + char *anton = "Anton"; + + printf ("%d\n", anton < zacharias); + printf ("%d\n", zacharias < anton); + printf ("%d\n", anton == anton); + + return 0; + + char buffer[100] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + + return 0; +} diff --git a/20231026/string-ops-03.s b/20231026/string-ops-03.s new file mode 100644 index 0000000000000000000000000000000000000000..32c8f593e5e2a00a03a2989fc0bf1ea6ddb9716c --- /dev/null +++ b/20231026/string-ops-03.s @@ -0,0 +1,57 @@ + .file "string-ops-03.c" + .text + .section .rodata +.LC0: + .string "Zacharias" +.LC1: + .string "Anton" +.LC2: + .string "%d\n" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + addq $-128, %rsp + leaq .LC0(%rip), %rax + movq %rax, -8(%rbp) + leaq .LC1(%rip), %rax + movq %rax, -16(%rbp) + movq -16(%rbp), %rax + cmpq -8(%rbp), %rax + setb %al + movzbl %al, %eax + movl %eax, %esi + leaq .LC2(%rip), %rax + movq %rax, %rdi + movl $0, %eax + call printf@PLT + movq -8(%rbp), %rax + cmpq -16(%rbp), %rax + setb %al + movzbl %al, %eax + movl %eax, %esi + leaq .LC2(%rip), %rax + movq %rax, %rdi + movl $0, %eax + call printf@PLT + movl $1, %esi + leaq .LC2(%rip), %rax + movq %rax, %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20231026/string-ops-04.c b/20231026/string-ops-04.c new file mode 100644 index 0000000000000000000000000000000000000000..3f0c0f75cece4d85260aa373e0e15c0808d7ba64 --- /dev/null +++ b/20231026/string-ops-04.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + + printf ("%d\n", anton < zacharias); + printf ("%d\n", zacharias < anton); + printf ("%d\n", anton == anton); + + return 0; + + char buffer[100] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + + return 0; +} diff --git a/20231026/string-ops-04.s b/20231026/string-ops-04.s new file mode 100644 index 0000000000000000000000000000000000000000..426782c50ddf95e4edae648686854029d27462cb --- /dev/null +++ b/20231026/string-ops-04.s @@ -0,0 +1,48 @@ + .file "string-ops-04.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Anton" +.LC1: + .string "Zacha" +.LC2: + .string "%d\n" + .text + .globl main + .type main, @function +main: +.LFB11: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + leaq .LC0(%rip), %rdx + leaq .LC1(%rip), %rax + cmpq %rax, %rdx + setb %sil + movzbl %sil, %esi + leaq .LC2(%rip), %rdi + movl $0, %eax + call printf@PLT + leaq .LC1(%rip), %rdx + leaq .LC0(%rip), %rax + cmpq %rax, %rdx + setb %sil + movzbl %sil, %esi + leaq .LC2(%rip), %rbx + movq %rbx, %rdi + movl $0, %eax + call printf@PLT + movl $1, %esi + movq %rbx, %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20231026/string-ops-05.c b/20231026/string-ops-05.c new file mode 100644 index 0000000000000000000000000000000000000000..e2730045918a81ce9a15cd5f28f1bcf6c8b8c1b9 --- /dev/null +++ b/20231026/string-ops-05.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[100] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + + return 0; +} diff --git a/20231026/string-ops-06.c b/20231026/string-ops-06.c new file mode 100644 index 0000000000000000000000000000000000000000..fb88b5574a0918dfcfd875df002bab8b848c8104 --- /dev/null +++ b/20231026/string-ops-06.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + + return 0; +} diff --git a/20231026/string-ops-07.c b/20231026/string-ops-07.c new file mode 100644 index 0000000000000000000000000000000000000000..b70d6cc345acfbdc0026ba9f9abc785ee9a2cade --- /dev/null +++ b/20231026/string-ops-07.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, anton); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-08.c b/20231026/string-ops-08.c new file mode 100644 index 0000000000000000000000000000000000000000..7eef447e240773dc8b82b3afb010a714b5f3aa66 --- /dev/null +++ b/20231026/string-ops-08.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, "Antonius, genannt Toni oder Anton"); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-09.c b/20231026/string-ops-09.c new file mode 100644 index 0000000000000000000000000000000000000000..61378965b9f51c8d3ec51d58a1490468bbaa70b4 --- /dev/null +++ b/20231026/string-ops-09.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + char *toni = "Antonius, genannt Toni oder Anton"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, toni); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-10.c b/20231026/string-ops-10.c new file mode 100644 index 0000000000000000000000000000000000000000..c9b792ea424718aa09047787e20389f3e1620d58 --- /dev/null +++ b/20231026/string-ops-10.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + char *toni = "Antonius!!"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, toni); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-11.c b/20231026/string-ops-11.c new file mode 100644 index 0000000000000000000000000000000000000000..d62f391603ee2667e718ef1274222b93c6556cce --- /dev/null +++ b/20231026/string-ops-11.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + char *toni = "Antonius!"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, toni); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-11.s b/20231026/string-ops-11.s new file mode 100644 index 0000000000000000000000000000000000000000..c61b7be3ac4ba70fcfe656d381a8592c944c0eee --- /dev/null +++ b/20231026/string-ops-11.s @@ -0,0 +1,55 @@ + .file "string-ops-11.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "%d\n" +.LC1: + .string "Anton" + .text + .globl main + .type main, @function +main: +.LFB11: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + movl $-1, %esi + leaq .LC0(%rip), %rbx + movq %rbx, %rdi + movl $0, %eax + call printf@PLT + movl $1, %esi ; #include <stdio.h> + movq %rbx, %rdi ; #include <string.h> + movl $0, %eax ; + call printf@PLT ; int main (void) + movl $0, %esi ; { + movq %rbx, %rdi ; char *zacharias = "Zacha"; + movl $0, %eax ; char *anton = "Anton"; + call printf@PLT ; char *toni = "Antonius!"; + movl $1700951368, 9(%rsp) ; + movl $2126437, 12(%rsp) ; printf ("%d\n", strcmp (anton, zacharias)); + leaq 9(%rsp), %rbx ; printf ("%d\n", strcmp (zacharias, anton)); + movq %rbx, %rdi ; printf ("%d\n", strcmp (anton, anton)); + call strlen@PLT ; + addq %rbx, %rax ; char buffer[] = "Huber "; + movabsq $8319671809674079809, %rdx ; strcat (buffer, toni); + movq %rdx, (%rax) ; printf ("%s\n", buffer); + movw $33, 8(%rax) ; printf ("%s\n", anton); + movq %rbx, %rdi ; + call puts@PLT ; return 0; + leaq .LC1(%rip), %rdi ; } + call puts@PLT + movl $0, %eax + addq $16, %rsp + .cfi_def_cfa_offset 16 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20231026/string-ops-12.c b/20231026/string-ops-12.c new file mode 100644 index 0000000000000000000000000000000000000000..bed94d67f1d0ba8fd68f22489492582f90935a8e --- /dev/null +++ b/20231026/string-ops-12.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + char *toni = "Toni"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[] = "Huber "; + strcat (buffer, toni); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-12.s b/20231026/string-ops-12.s new file mode 100644 index 0000000000000000000000000000000000000000..f382c413e325443aa8c264bf8057e426838cd0dd --- /dev/null +++ b/20231026/string-ops-12.s @@ -0,0 +1,54 @@ + .file "string-ops-12.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "%d\n" +.LC1: + .string "Anton" + .text + .globl main + .type main, @function +main: +.LFB11: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $16, %rsp ; #include <stdio.h> + .cfi_def_cfa_offset 32 ; #include <string.h> + movl $-1, %esi ; + leaq .LC0(%rip), %rbx ; int main (void) + movq %rbx, %rdi ; { + movl $0, %eax ; char *zacharias = "Zacha"; + call printf@PLT ; char *anton = "Anton"; + movl $1, %esi ; char *toni = "Toni"; + movq %rbx, %rdi ; + movl $0, %eax ; printf ("%d\n", strcmp (anton, zacharias)); + call printf@PLT ; printf ("%d\n", strcmp (zacharias, anton)); + movl $0, %esi ; printf ("%d\n", strcmp (anton, anton)); + movq %rbx, %rdi ; + movl $0, %eax ; char buffer[] = "Huber "; + call printf@PLT ; strcat (buffer, toni); + movl $1700951368, 9(%rsp) ; printf ("%s\n", buffer); + movl $2126437, 12(%rsp) ; printf ("%s\n", anton); + leaq 9(%rsp), %rbx ; + movq %rbx, %rdi ; return 0; + call strlen@PLT ; } + addq %rbx, %rax + movl $1768845140, (%rax) + movb $0, 4(%rax) + movq %rbx, %rdi + call puts@PLT + leaq .LC1(%rip), %rdi + call puts@PLT + movl $0, %eax + addq $16, %rsp + .cfi_def_cfa_offset 16 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20231026/string-ops-13.c b/20231026/string-ops-13.c new file mode 100644 index 0000000000000000000000000000000000000000..150e9f4b52047c52cfba3fbff9ebdf3af57189ec --- /dev/null +++ b/20231026/string-ops-13.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + char *toni = "Antonius, genannt Toni"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[13] = "Huber "; + strncat (buffer, toni, 13); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-14.c b/20231026/string-ops-14.c new file mode 100644 index 0000000000000000000000000000000000000000..e290ca83e10fc236694d4b181b691d01f8e3b063 --- /dev/null +++ b/20231026/string-ops-14.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *zacharias = "Zacha"; + char *anton = "Anton"; + char *toni = "Antonius, genannt Toni"; + + printf ("%d\n", strcmp (anton, zacharias)); + printf ("%d\n", strcmp (zacharias, anton)); + printf ("%d\n", strcmp (anton, anton)); + + char buffer[14] = "Huber "; + strncat (buffer, toni, 13); + printf ("%s\n", buffer); + printf ("%s\n", anton); + + return 0; +} diff --git a/20231026/string-ops-15.c b/20231026/string-ops-15.c new file mode 100644 index 0000000000000000000000000000000000000000..731a6b182fcc38e984565425a141d50bb09893df --- /dev/null +++ b/20231026/string-ops-15.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[100] = ""; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Antwort"); + printf ("%s\n", answer); + printf ("found at: %zd\n", answer - buffer); + + return 0; +} diff --git a/20231026/string-ops-16.c b/20231026/string-ops-16.c new file mode 100644 index 0000000000000000000000000000000000000000..1db6aa51e39634f5efc4a5acf2818f521f98427a --- /dev/null +++ b/20231026/string-ops-16.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[100] = ""; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + printf ("%s\n", answer); + printf ("found at: %zd\n", answer - buffer); + + return 0; +} diff --git a/20231026/string-ops-17.c b/20231026/string-ops-17.c new file mode 100644 index 0000000000000000000000000000000000000000..afa66c6346051652ba558f73f41e8d28562761a3 --- /dev/null +++ b/20231026/string-ops-17.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[100] = ""; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + printf ("found at: %zd\n", answer - buffer); + printf ("%s\n", answer); + + return 0; +} diff --git a/20231026/string-ops-18.c b/20231026/string-ops-18.c new file mode 100644 index 0000000000000000000000000000000000000000..27ecc2af148320e46d788a9f767023bc35ebb6f3 --- /dev/null +++ b/20231026/string-ops-18.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[100] = ""; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + printf ("answer = %zd\n", answer); + printf ("buffer = %zd\n", buffer); + printf ("found at: %zd\n", answer - buffer); + printf ("%s\n", answer); + + return 0; +} diff --git a/20231026/string-ops-19.c b/20231026/string-ops-19.c new file mode 100644 index 0000000000000000000000000000000000000000..b9391e1b0c498cdae057838eae40e60700aece90 --- /dev/null +++ b/20231026/string-ops-19.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[100] = ""; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + if (answer) + printf ("found at: %zd\n", answer - buffer); + else + printf ("not found\n"); + + return 0; +} diff --git a/20231026/string-ops-20.c b/20231026/string-ops-20.c new file mode 100644 index 0000000000000000000000000000000000000000..6caf32446147b5e123b9e5ac2b74183becf692e8 --- /dev/null +++ b/20231026/string-ops-20.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[10] = ""; + sprintf (buffer, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + if (answer) + printf ("found at: %zd\n", answer - buffer); + else + printf ("not found\n"); + + return 0; +} diff --git a/20231026/string-ops-21.c b/20231026/string-ops-21.c new file mode 100644 index 0000000000000000000000000000000000000000..92185276f658bb4e67c32a8a35d7cd9aef37ecf7 --- /dev/null +++ b/20231026/string-ops-21.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[10] = ""; + snprintf (buffer, 10, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + if (answer) + printf ("found at: %zd\n", answer - buffer); + else + printf ("not found\n"); + + return 0; +} diff --git a/20231026/string-ops-22.c b/20231026/string-ops-22.c new file mode 100644 index 0000000000000000000000000000000000000000..a487160f4aaecca2c0051b1be51a82866c2982dd --- /dev/null +++ b/20231026/string-ops-22.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char buffer[11] = ""; + snprintf (buffer, 10, "Die Antwort lautet: %d", 42); + printf ("%s\n", buffer); + + char *answer = strstr (buffer, "Bntwort"); + if (answer) + printf ("found at: %zd\n", answer - buffer); + else + printf ("not found\n"); + + return 0; +}