Sign in Join
Wiki copytemporary

Char/fr

Deutsch · English · Español · Français · Italiano · Русский

Un char est un simple caractère. Un octet et un char sont la même chose, excepté qu'un char peut être employé comme caractère, ou en tant qu'élément de type chaîne de caractères, et ne peut pas être employé dans une expression arithmétique, tandis qu'un octet peut seulement se rapporter à un type numérique.

Par exemple :

pascal
 var ch: char;
 c: byte; 

 begin
   ch := 'A';  c := 64;  { ont la même action, et sont légaux  }
   ch := 64;   c := 'A'; { bien qu'ils aient la même action , c'est illégal  }
 end.

L'utilisation de char ou de byte comme type de données fournit une meilleure documentation quant au but d'utiliser une variable particulière. Le type char peut être contraint vers le type byte en employant la fonction ord. Les valeurs de type byte peuvent être contrainte vers le type char en employant la fonction chr.

Les fonctions manipulant les caractères, suivent la norme ASCII.

Le programme ci-dessus, corrigé pour une utilisation légale :

pascal
 var ch: char;
 c: byte; 

 begin
  ch := 'A';  c := 64; { ont la même action, et sont légaux }
  ch := chr(64); c := ord('A'); { maintenant légal  }
 end.

Voir aussi


From the Free Pascal wiki, page "Char/fr", as it stood on 2020-01-24 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 7 people, 2007–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
PaulatreidesNew page: {{Char}} A '''char''' is a single character. A byte and a char are the same thing, except a char can be used as a character, or as part of a string type, and cannot b...
Paulatreides
Paulatreides
Paulatreides
EjcaTypo
Paulatreides
Paulatreides
Paulatreides
Paulatreides
VincentText replace - "delphi>" to "syntaxhighlight>" (minor)
Olaf (minor)
Olaf (minor)
E-ric (minor)
E-ric
E-ric
E-ric
E-ric (minor)
FTurtle
FTurtle
E-ric (minor)
E-ric (minor)
BartUse pascal highlighter

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.