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

Beispiele und Tafelbilder 16.3.2023, Vorbereitung 23.3.2023

parent df1eaae6
No related branches found
No related tags found
No related merge requests found
Showing
with 177 additions and 1 deletion
20230316/ad-20230316-1-array-und-pointer.png

58.9 KiB

20230316/ad-20230316-2-pointer-auf-pointer.png

72.3 KiB

20230316/ad-20230316-3-array-von-arrays.png

79.1 KiB

No preview for this file type
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
{\color{medgreen}\textbf{Differentialgleichungen}} {\color{medgreen}\textbf{Differentialgleichungen}}
\begin{itemize} \begin{itemize}
\item Pendel \item Pendel
\item Basketball \item Planetenbahnen
\end{itemize} \end{itemize}
{\color{medgreen}\textbf{Rekursion}} {\color{medgreen}\textbf{Rekursion}}
...@@ -627,6 +627,10 @@ ...@@ -627,6 +627,10 @@
\arrowitem \arrowitem
Fazit:\\ Fazit:\\
Ein Hoch auf \lstinline{typedef}! Ein Hoch auf \lstinline{typedef}!
\arrowitem
Trotzdem: {\color{red}Vorsicht!}\\
Ein \lstinline{p++} auf einen Zeiger vom Typ \lstinline{string5 *p}\\
ergibt anscheinend undefiniertes Verhalten!
\end{itemize} \end{itemize}
\end{frame} \end{frame}
......
File added
#include <stdio.h>
char a[] = "Test";
char *p = "Test";
int main (void)
{
char *q;
q = a;
printf ("%016zx: %s\n", q, q);
q = &a;
printf ("%016zx: %s\n", q, q);
q = p;
printf ("%016zx: %s\n", q, q);
q = &p;
printf ("%016zx: %s\n", q, q);
return 0;
}
#include <stdio.h>
char *a[] = { "Dies", "ist", "ein", "Test", NULL };
int main (void)
{
for (char **p = a; *p; p++)
printf ("%s\n", *p);
return 0;
}
#include <stdio.h>
char a[][] = { "Dies", "ist", "ein", "Test", NULL };
int main (void)
{
for (char **p = a; *p; p++)
printf ("%s\n", *p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", NULL };
int main (void)
{
for (char **p = a; *p; p++)
printf ("%s\n", *p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", NULL };
int main (void)
{
for (char *p = a; *p; p++)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", NULL };
int main (void)
{
for (char *p = a; *p; p += 5)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", "" };
/* "NULL" ist ein Zeiger mit Wert 0
und wird hier uminterpretiert zu
einer Speicherzelle mit Wert 0,
also zu einem Leerstring. */
int main (void)
{
for (char *p = a; *p; p += 5)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", "" };
/* "NULL" ist ein Zeiger mit Wert 0
und wird hier uminterpretiert zu
einer Speicherzelle mit Wert 0,
also zu einem Leerstring. */
int main (void)
{
for (char *p = &a; *p; p += 5)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", "" };
/* "NULL" ist ein Zeiger mit Wert 0
und wird hier uminterpretiert zu
einer Speicherzelle mit Wert 0,
also zu einem Leerstring. */
int main (void)
{
for (char *p[5] = a; *p; p += 5)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
char a[][5] = { "Dies", "ist", "ein", "Test", "" };
/* "NULL" ist ein Zeiger mit Wert 0
und wird hier uminterpretiert zu
einer Speicherzelle mit Wert 0,
also zu einem Leerstring. */
int main (void)
{
for (char *p = a[0]; *p; p += 5)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
typedef char short_string[5];
short_string a[] = { "Dies", "ist", "ein", "Test", "" };
int main (void)
{
for (short_string *p = a; *p; p++)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
typedef char short_string[5];
short_string a[] = { "Dies", "ist", "ein", "Test", "" };
int main (void)
{
for (short_string *p = a; p[0]; p++)
printf ("%s\n", p);
return 0;
}
#include <stdio.h>
typedef char short_string[5];
short_string a[] = { "Dies", "ist", "ein", "Test", "" };
int main (void)
{
for (short_string *p = a; p[0]; p++)
printf ("%s\n", *p);
return 0;
}
#include <stdio.h>
typedef char short_string[5];
short_string a[] = { "Dies", "ist", "ein", "Test", "" };
int main (void)
{
for (short_string *p = a; p[0]; p++)
printf ("%016zx: %s\n", (size_t) p, *p);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment