Skip to content
Snippets Groups Projects
Verified Commit 747284dd authored by orestis.malaspin's avatar orestis.malaspin
Browse files

minor update

parent 5e17fd3c
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,41 @@ date: "2022-02-22"
```
* À la programmeuse de faire attention à ce qu'elle fait.
## Exemple
```C
struct tab {
int *t;
}
struct tab *tmp = malloc();
tmp->t = malloc();
free(tmp); // memory leak of tmp->t...
```
# Exemple simple
* On souhaite échanger deux pointeurs
```C
int *a = malloc();
int *b = malloc();
swap(&a, &b);
```
* Comment écrire `swap()` pour que le code ci-dessus marche pour n'importe quel
type?
. . .
```C
void swap(void **a, void **b) {
void *tmp = *a;
*a = *b;
*b = tmp;
}
```
# Cas d'utilisation (1/4)
\footnotesize
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment