diff --git a/20211115/addresses-1.c b/20211115/addresses-1.c new file mode 100644 index 0000000000000000000000000000000000000000..935be5612a97f4f6b74efb2652b1205d23629f60 --- /dev/null +++ b/20211115/addresses-1.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + char *hello = "Hello, world!"; + uint64_t a = hello; + printf ("a = %lu\n", a); + return 0; +} diff --git a/20211115/addresses-2.c b/20211115/addresses-2.c new file mode 100644 index 0000000000000000000000000000000000000000..338bbbc863eb2793abd4208a625b4e0fdd10011b --- /dev/null +++ b/20211115/addresses-2.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + char *hello = "Hello, world!"; + uint64_t a = hello; + uint32_t b = hello; + uint16_t c = hello; + uint8_t d = hello; + char e = hello; + printf ("a = %lu\n", a); + printf ("b = %u\n", b); + printf ("c = %hu\n", c); + printf ("d = %hhu\n", d); + printf ("e = %d\n", e); + return 0; +} diff --git a/20211115/addresses-3.c b/20211115/addresses-3.c new file mode 100644 index 0000000000000000000000000000000000000000..58bf55dad27898773774ba558b146b979f53f92b --- /dev/null +++ b/20211115/addresses-3.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + char *hello = "Hello, world!"; + uint64_t a = hello; + uint32_t b = hello; + uint16_t c = hello; + uint8_t d = hello; + char e = hello; + printf ("a = %016lx\n", a); + printf ("b = %08x\n", b); + printf ("c = %04x\n", c); + printf ("d = %02x\n", d); + printf ("e = %02x\n", e); + return 0; +} diff --git a/20211115/addresses-4.c b/20211115/addresses-4.c new file mode 100644 index 0000000000000000000000000000000000000000..3b9d9f3205c45a8cc29f18d8c7cd3a323b20dd40 --- /dev/null +++ b/20211115/addresses-4.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + char *hello = "Hello, world!"; + uint64_t a = (uint64_t) hello; + uint32_t b = (uint32_t) hello; + uint16_t c = (uint16_t) hello; + uint8_t d = (uint8_t) hello; + char e = (char) hello; + printf ("a = %016lx\n", a); + printf ("b = %08x\n", b); + printf ("c = %04x\n", c); + printf ("d = %02x\n", d); + printf ("e = %02x\n", e); + return 0; +} diff --git a/20211115/addresses-5.c b/20211115/addresses-5.c new file mode 100644 index 0000000000000000000000000000000000000000..8854d9237864cc34336adb70319668495c02b0a9 --- /dev/null +++ b/20211115/addresses-5.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + char *hello = "Hello, world!"; + uint64_t a = (uint64_t) hello; + uint32_t b = (uint64_t) hello; + uint16_t c = (uint64_t) hello; + uint8_t d = (uint64_t) hello; + char e = (uint64_t) hello; + printf ("a = %016lx\n", a); + printf ("b = %08x\n", b); + printf ("c = %04x\n", c); + printf ("d = %02x\n", d); + printf ("e = %02x\n", e); + return 0; +} diff --git a/20211115/addresses-6.c b/20211115/addresses-6.c new file mode 100644 index 0000000000000000000000000000000000000000..6f11d434a57d40378dfc0b593b8fb84e1038e36c --- /dev/null +++ b/20211115/addresses-6.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + char *hello = "Hello, world!"; + uint64_t a = (size_t) hello; + uint32_t b = (size_t) hello; + uint16_t c = (size_t) hello; + uint8_t d = (size_t) hello; + char e = (size_t) hello; + printf ("a = %016lx\n", a); + printf ("b = %08x\n", b); + printf ("c = %04x\n", c); + printf ("d = %02x\n", d); + printf ("e = %02x\n", e); + return 0; +} diff --git a/20211115/arrays-pointers-1.c b/20211115/arrays-pointers-1.c new file mode 100644 index 0000000000000000000000000000000000000000..331e8d3cd1cff5be4f52cf6efcff042e4d06311d --- /dev/null +++ b/20211115/arrays-pointers-1.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char hello[] = "Hello, world!"; + char *p = hello; + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-10.c b/20211115/arrays-pointers-10.c new file mode 100644 index 0000000000000000000000000000000000000000..059013b08cc2ed0b9be387b3e9faaad569b510af --- /dev/null +++ b/20211115/arrays-pointers-10.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char *p = hello; + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-11.c b/20211115/arrays-pointers-11.c new file mode 100644 index 0000000000000000000000000000000000000000..c59ae2c51603e50018a6776b67c430e922d4f764 --- /dev/null +++ b/20211115/arrays-pointers-11.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[] = { hello }; + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-12.c b/20211115/arrays-pointers-12.c new file mode 100644 index 0000000000000000000000000000000000000000..5a1f2bbf7b8c757934a365ba2b0a947c4e6c9778 --- /dev/null +++ b/20211115/arrays-pointers-12.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[] = { hello }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-13.c b/20211115/arrays-pointers-13.c new file mode 100644 index 0000000000000000000000000000000000000000..ef79bf612263113c3e57bc18f754db2a0d8ed5d2 --- /dev/null +++ b/20211115/arrays-pointers-13.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char p[14] = { '*' }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-14.c b/20211115/arrays-pointers-14.c new file mode 100644 index 0000000000000000000000000000000000000000..aa6c1177dc1a62ef7760449b4c30b282c3b2a44f --- /dev/null +++ b/20211115/arrays-pointers-14.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char *p[14] = { hello }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p[1]); + return 0; +} diff --git a/20211115/arrays-pointers-15.c b/20211115/arrays-pointers-15.c new file mode 100644 index 0000000000000000000000000000000000000000..fa859c091c89f3c32492bb35481da9a8140be32d --- /dev/null +++ b/20211115/arrays-pointers-15.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char *p[14] = { hello }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p[0]); + return 0; +} diff --git a/20211115/arrays-pointers-16.c b/20211115/arrays-pointers-16.c new file mode 100644 index 0000000000000000000000000000000000000000..2ac4390f59f85a11e4c111a8f1d40de6b28aa39b --- /dev/null +++ b/20211115/arrays-pointers-16.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[] = { hello - 150 }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-17.c b/20211115/arrays-pointers-17.c new file mode 100644 index 0000000000000000000000000000000000000000..d290e792faf68b76b970578e7bc45d03ad21efb0 --- /dev/null +++ b/20211115/arrays-pointers-17.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[] = { hello + 'a' }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-18.c b/20211115/arrays-pointers-18.c new file mode 100644 index 0000000000000000000000000000000000000000..8d39757fd1ee1c18fdcdff8d01ab55fb048cebc6 --- /dev/null +++ b/20211115/arrays-pointers-18.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + char p[] = { 4 + 'a' }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-19.c b/20211115/arrays-pointers-19.c new file mode 100644 index 0000000000000000000000000000000000000000..e975ca53f385e534b167a60e64a0a1579b6bbc52 --- /dev/null +++ b/20211115/arrays-pointers-19.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hallo, Welt!"; + char p[] = { hello + 'a' }; /* ein Element des Arrays initialisieren */ + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-2.c b/20211115/arrays-pointers-2.c new file mode 100644 index 0000000000000000000000000000000000000000..42e0f3d2f272fee5aad0e3ff396f8402d4afe7ac --- /dev/null +++ b/20211115/arrays-pointers-2.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[] = hello; + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-3.c b/20211115/arrays-pointers-3.c new file mode 100644 index 0000000000000000000000000000000000000000..7f489ccceadc5a071626b509561f9cdd013c8374 --- /dev/null +++ b/20211115/arrays-pointers-3.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + int a = 3; + int b = a; + printf ("%d\n", b); + return 0; +} diff --git a/20211115/arrays-pointers-4.c b/20211115/arrays-pointers-4.c new file mode 100644 index 0000000000000000000000000000000000000000..9e9335ebaa6dae7da1b6315c9168dcd1ac74d4f6 --- /dev/null +++ b/20211115/arrays-pointers-4.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int a = 3; +int b = a; + +int main (void) +{ + printf ("%d\n", b); + return 0; +} diff --git a/20211115/arrays-pointers-5.c b/20211115/arrays-pointers-5.c new file mode 100644 index 0000000000000000000000000000000000000000..e805a37afd650684b54dca364a46241099d344ea --- /dev/null +++ b/20211115/arrays-pointers-5.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[13] = hello; + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-6.c b/20211115/arrays-pointers-6.c new file mode 100644 index 0000000000000000000000000000000000000000..0b6560d901ee02d4c5e9134b8776ff01b551000b --- /dev/null +++ b/20211115/arrays-pointers-6.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[13]; + strcpy (p, hello); + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-7.c b/20211115/arrays-pointers-7.c new file mode 100644 index 0000000000000000000000000000000000000000..26a064b907be4ba82d041c0a873d455845c68455 --- /dev/null +++ b/20211115/arrays-pointers-7.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[14]; + strcpy (p, hello); + printf ("%s\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-8.c b/20211115/arrays-pointers-8.c new file mode 100644 index 0000000000000000000000000000000000000000..928ecb48df1f767c083932d76865d3e1bc5164cb --- /dev/null +++ b/20211115/arrays-pointers-8.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[14]; + strcpy (p, hello); + printf ("%c\n", p); + return 0; +} diff --git a/20211115/arrays-pointers-9.c b/20211115/arrays-pointers-9.c new file mode 100644 index 0000000000000000000000000000000000000000..ebeae790cbe495212e30efd54e3cb7ba9fbd7271 --- /dev/null +++ b/20211115/arrays-pointers-9.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> + +int main (void) +{ + char *hello = "Hello, world!"; + char p[14]; + strcpy (p, hello); + printf ("%c\n", p[1]); + return 0; +}