lang:c:variable
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
lang:c:variable [2020/03/04 23:25] – Ajout de la source pour "Les types fondamentaux" root | lang:c:variable [2023/02/22 10:54] (Version actuelle) – Ajout de Pointeurs root | ||
---|---|---|---|
Ligne 36: | Ligne 36: | ||
'' | '' | ||
+ | |||
+ | ====Pointeurs==== | ||
+ | |||
+ | * Influence de la position des '' | ||
+ | |||
+ | <code c> | ||
+ | int main() { | ||
+ | int a; | ||
+ | int* b = &a; | ||
+ | b = &a; | ||
+ | *b = 1; | ||
+ | const int* c = &a; | ||
+ | c = &a; | ||
+ | *c = 1; // error: assignment of read-only location '* c' | ||
+ | int const* d = &a; | ||
+ | d = &a; | ||
+ | *d = 1; // error: assignment of read-only location '* d' | ||
+ | int* const e = &a; | ||
+ | e = & | ||
+ | *e = 1; | ||
+ | int const* const f = &a; | ||
+ | f = & | ||
+ | *f = 1; // error: assignment of read-only location ' | ||
+ | } | ||
+ | </ |
lang/c/variable.1583360710.txt.gz · Dernière modification : 2020/03/04 23:25 de root