« Programmation C/Opérateurs » : différence entre les versions

Contenu supprimé Contenu ajouté
→‎Évaluation des expressions booléennes : Le but est de montrer l'erreur
Ligne 17 :
 
{| cellpadding="5" cellspacing="0" style="border:thin black solid"
| style="background:#D0E2EE438bbb40; text-align:center; font-weight:bold;" |opérateur
| style="background:#ECE5CAb3972b40; text-align:center; font-weight:bold;" |parité
| style="background:#D0E2EE438bbb40; text-align:center; font-weight:bold;" |associativité
| style="background:#ECE5CAb3972b40; text-align:center; font-weight:bold;" |description
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>( )</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |
| bgcolorstyle="background:#EAF5FBabd7ef40" |gauche vers la droite (GD)
| bgcolorstyle="background:#FAF9ECebe7b340" |parenthésage
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>[[Programmation C/Fonctions et procédures|()]] [[Programmation C/Tableaux|[]]] [[Programmation C Types avancés#Acc.C3.A8s aux champs|.]] [[Programmation C Types avancés#Pointeurs vers structures|->]]</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |appel de fonction, index de tableau, membre de structure, pointe sur membre de structure
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>!</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |droite vers la gauche (DG)
| bgcolorstyle="background:#FAF9ECebe7b340" |négation booléenne
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>~</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |négation binaire
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>++ --</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |incrémentation et décrémentation
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>-</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |opposé
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>(''type'')</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |opérateur de transtypage (cast)
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>[[Programmation C Pointeurs#Déréférencement|*]]</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |opérateur de déréférencement (ou indirection)
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>[[Programmation C Pointeurs#Usage et d.C3.A9claration|&]]</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |opérateur de référencement (ou d'adresse)
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>sizeof</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |unaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |fournit la taille en nombre de "char" de l'expression (souvent en octet mais pas toujours, mais sizeof(char) == 1 par définition, voir [[Programmation C Types de base#Caractères|Caractères]])
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>* / %</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |multiplication, division, modulo (reste de la division)
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>+ -</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |addition, soustraction
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>>> <<</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |décalages de bits
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>> >= < <=</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |comparaisons
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>== !=</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |égalité/différence
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>&</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |'''et''' binaire
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>^</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |'''ou''' exclusif binaire
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code><nowiki>|</nowiki></code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |'''ou''' inclusif binaire
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>&&</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |'''et''' logique avec séquencement
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code><nowiki>||</nowiki></code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |'''ou''' logique avec séquencement
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>[[Programmation C Tests#Expression conditionnelle|? :]]</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |ternaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |'''si...alors...sinon'''
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>= += -= *= /= %= ^= &amp;= |= &gt;&gt;= &lt;&lt;=</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |DG
| bgcolorstyle="background:#FAF9ECebe7b340" |affectation
|-
| bgcolorstyle="background:#EAF5FBabd7ef40" |<code>,</code>
| bgcolorstyle="background:#FAF9ECebe7b340" |binaire
| bgcolorstyle="background:#EAF5FBabd7ef40" |GD
| bgcolorstyle="background:#FAF9ECebe7b340" |séquencement
|}
 
=== Post/pré incrémentation/décrémentation ===