www.delorie.com/gnu/docs/gcc/g77_212.html   search  
 
Buy the book!


Using and Porting GNU Fortran

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.11.9.137 IChar Intrinsic

 
IChar(C)

IChar: INTEGER(KIND=1) function.

C: CHARACTER; scalar; INTENT(IN).

Intrinsic groups: (standard FORTRAN 77).

Description:

Returns the code for the character in the first character position of C.

Because the system's native character set is used, the correspondence between character and their codes is not necessarily the same between GNU Fortran implementations.

Note that no intrinsic exists to convert a printable character string to a numerical value. For example, there is no intrinsic that, given the CHARACTER value `'154'', returns an INTEGER or REAL value with the value `154'.

Instead, you can use internal-file I/O to do this kind of conversion. For example:

 
INTEGER VALUE
CHARACTER*10 STRING
STRING = '154'
READ (STRING, '(I10)'), VALUE
PRINT *, VALUE
END

The above program, when run, prints:

 
 154

See section 8.11.9.39 Char Intrinsic, for the inverse of the ICHAR function.

See section 8.11.9.131 IAChar Intrinsic, for the function corresponding to the ASCII character set.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003