Fortran Wiki
ichar

Description

ichar(c) returns the code for the character in the first character position of c in the system’s native character set. The correspondence between characters and their codes is not necessarily the same across different GNU Fortran implementations.

Syntax

Arguments

Return value

The return value is of type integer and of kind kind. If kind is absent, the return value is of default integer kind.

Example

program test_icharintegerii=ichar(' ')endprogram test_ichar

Note

No intrinsic exists to convert between a numeric value and a formatted character string representation – for instance, given the character value '154', obtaining an integer or real value with the value 154, or vice versa. Instead, this functionality is provided by internal-file I/O, as in the following example:

program read_valintegervaluecharacter(len=10)string,string2string='154'! Convert a string to a numeric valueread(string,'(I10)')valueprint*,value! Convert a value to a formatted stringwrite(string2,'(I10)')valueprint*,string2endprogram read_val