Skip to content
Snippets Groups Projects
Commit ea056fd8 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiele und Tafelbilder 25.3.2025

parent 6553afd4
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
int main (void)
{
typedef char string5[5];
string5 *p = { "Dies", "ist", "ein", "Test" };
for (int i = 0; i < 4; i++)
printf ("%s\n", p[i]);
return 0;
}
#include <stdio.h>
int main (void)
{
typedef char string5[5];
string5 *p = { "Dies", "ist", "ein", "Test" };
for (int i = 0; i < 4; i++)
printf ("%s\n", p[i]);
return 0;
}
cassini/home/peter/bo/2025ss/ad/20250325> gcc -Wall -O3 arrays-and-pointers-24.c
arrays-and-pointers-24.c: In function ‘main’:
arrays-and-pointers-24.c:6:18: warning: initialization of ‘char (*)[5]’ from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
6 | string5 *p = { "Dies", "ist", "ein", "Test" };
| ^~~~~~
arrays-and-pointers-24.c:6:18: note: (near initialization for ‘p’)
arrays-and-pointers-24.c:6:26: warning: excess elements in scalar initializer
6 | string5 *p = { "Dies", "ist", "ein", "Test" };
| ^~~~~
arrays-and-pointers-24.c:6:26: note: (near initialization for ‘p’)
arrays-and-pointers-24.c:6:33: warning: excess elements in scalar initializer
6 | string5 *p = { "Dies", "ist", "ein", "Test" };
| ^~~~~
arrays-and-pointers-24.c:6:33: note: (near initialization for ‘p’)
arrays-and-pointers-24.c:6:40: warning: excess elements in scalar initializer
6 | string5 *p = { "Dies", "ist", "ein", "Test" };
| ^~~~~~
arrays-and-pointers-24.c:6:40: note: (near initialization for ‘p’)
arrays-and-pointers-24.c:8:22: warning: array subscript 10 is outside array bounds of ‘char[5]’ [-Warray-bounds]
8 | printf ("%s\n", p[i]);
| ^
arrays-and-pointers-24.c:8:22: warning: array subscript 15 is outside array bounds of ‘char[5]’ [-Warray-bounds]
arrays-and-pointers-24.c:8:22: warning: offset ‘5’ outside bounds of constant string [-Warray-bounds]
arrays-and-pointers-24.c:8:22: warning: offset ‘10’ outside bounds of constant string [-Warray-bounds]
arrays-and-pointers-24.c:8:22: warning: offset ‘15’ outside bounds of constant string [-Warray-bounds]
cassini/home/peter/bo/2025ss/ad/20250325> ./a.out
Dies
;(
cassini/home/peter/bo/2025ss/ad/20250325>
#include <stdio.h>
int main (void)
{
typedef char string8[8];
string8 *p = { "Dies", "ist", "ein", "Test" };
for (int i = 0; i < 4; i++)
printf ("%s\n", p[i]);
return 0;
}
.file "arrays-and-pointers-25.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Dies"
.section .text.startup,"ax",@progbits
.p2align 4
.globl main
.type main, @function
main:
.LFB11:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
leaq .LC0(%rip), %rdi
call puts@PLT
leaq 8+.LC0(%rip), %rdi
call puts@PLT
leaq 16+.LC0(%rip), %rdi
call puts@PLT
leaq 24+.LC0(%rip), %rdi
call puts@PLT
xorl %eax, %eax
addq $8, %rsp
.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
Version 1:
Neues Programm: Array von Strings ausgeben
Version 2:
Nicht mehr Strings ausgeben, sondern die Adressen.
Version 3:
Adressen nicht mit %d ausgeben, sondern mit %z
[14:33:29] (Kanal) kriexinger:
https://semver.org/lang/de/ Diese Art Versionierung ist ganz gut, finde ich.
Wenn man es manuell machen wil....
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment