Struktur als pointer beispiel
Quellen auf Deutsch
This commit is contained in:
		
							
								
								
									
										36
									
								
								src/main.tex
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								src/main.tex
									
									
									
									
									
								
							| @@ -163,8 +163,7 @@ struct Adresse { | ||||
| 	int *nummer; | ||||
| 	short hausnummer; | ||||
| 	long plz; | ||||
| }; | ||||
|         \end{lstlisting} | ||||
| };\end{lstlisting} | ||||
|         Anwendung: | ||||
|         \begin{lstlisting} | ||||
| // Variable der Struktur erstellen | ||||
| @@ -172,9 +171,9 @@ struct Adresse adresseKurt; | ||||
| // Zugriff auf die Elemente | ||||
| strcpy(adresseKurt.name, "Kurt Kanns"); | ||||
| adresseKurt.hausnummer = 23; | ||||
| adresseKurt->nummer = 4; | ||||
| adresseKurt.plz = 45678; | ||||
|         \end{lstlisting} | ||||
| int nr = 4; | ||||
| adresseKurt.nummer = &nr; | ||||
| adresseKurt.plz = 45678;\end{lstlisting} | ||||
|  | ||||
|         \framebreak | ||||
|  | ||||
| @@ -195,7 +194,7 @@ ADR a1,a2; | ||||
|             \item Gesamtlänge der Struktur: sizeof(Struktur) | ||||
|             \item Zugriff auf einzelne Komponenten durch\\ | ||||
|             Punktnotation: Adresse1.Vorname = “Peter“; | ||||
|             \item Pfeilnotation (->) wenn Komponente ist Pointer | ||||
|             \item Pfeilnotation (->) wenn struct ist Pointer | ||||
|             \item Weiteres hinzufügen von Komponenten während der Laufzeit nicht möglich. | ||||
|         \end{itemize} | ||||
|     \end{frame} | ||||
| @@ -256,12 +255,12 @@ void beispiel() { | ||||
|    // Erstellen von root | ||||
|    node *root = malloc(sizeof(node)); | ||||
|  | ||||
|    root.data = 17; | ||||
|    root->data = 17; | ||||
|  | ||||
|    // Anhaengen eines Knotens | ||||
|    node *secondNode = malloc(sizeof(node)); | ||||
|    root->next = secondNode; | ||||
|    secondNode.data = 19; | ||||
|    secondNode->data = 19; | ||||
| } | ||||
|         \end{lstlisting} | ||||
|     \end{frame} | ||||
| @@ -269,7 +268,24 @@ void beispiel() { | ||||
| %------------------------------------------------ | ||||
|  | ||||
|     \begin{frame}[fragile]{Struktur als Pointer} | ||||
|         todo | ||||
|         \begin{lstlisting} | ||||
| struct mystruct { | ||||
|     int data; | ||||
| }; | ||||
| typedef struct mystruct mystruct; | ||||
|  | ||||
| void beispiel(mystruct * str) { | ||||
|     int d = str->data; | ||||
| } | ||||
|  | ||||
| int main(){ | ||||
|     mystruct struc; | ||||
|     struc.data = 5; | ||||
|     beispiel(&struc); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|         \end{lstlisting} | ||||
|     \end{frame} | ||||
|  | ||||
| %------------------------------------------------ | ||||
| @@ -284,7 +300,7 @@ void beispiel() { | ||||
|  | ||||
|     \appendix | ||||
|  | ||||
|     \begin{frame}{References} | ||||
|     \begin{frame}{Quellen} | ||||
|         \nocite{*} % Display all references regardless of if they were cited | ||||
|         \bibliography{quellen} | ||||
|         \bibliographystyle{plain} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user