Sign in Join
Wiki copytemporary

Revision 1 of 1, by Bart on 1-24-2020. The page as it is now.

Char/it

Una variabile char contiene un solo carattere. Un byte e un char sono la stessa cosa, con l'eccezione che un char può essere usato come carattere, o come parte di una stringa, e non può essere usata in espressioni aritmetiche, mentre un byte può solo essere riferito a un'espressione numerica.

Ad esempio:

pascal
 var ch: char;
     c: byte; 

 begin
   ch := 'A';  c := 64;  { sono la stessa azione, ed è legittimo }
   ch := 64;   c := 'A'; { questo è illegittimo }
 end.

L'uso di char o byte come data type permette una migliore comprensione dell'uso della particolare variabile. Il char può essere convertito in byte usando la funzione ord. I valori delle variabile byte può essere convertito in char tramite la funzione chr.

Le funzioni del char seguono il codice ASCII.

Il precedente programma reso legittimo:

pascal
 var ch: char;
     c: byte; 

 begin
   ch := 'A';  c := 64; { sono la stessa azione, e sono legittimi }
   ch := chr(64); c := ord('A'); { ora legittimo }
 end.

From the Free Pascal wiki, page "Char/it", 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.