Article ID: 120397
Article Last Modified on 11/18/2003
[whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits]
Use some caution and error checking when employing these functions. If
the atof or atoi function cannot convert the string format, it returns zero
(0.0 or 0) as the error condition. You should consult the C run-time
library reference for complete information on these functions.
CHARACTER*10 a
a(10:10) = char(0)
C Interface to the atof function which is in the LIBC library
INTERFACE to REAL*8 FUNCTION atof[C](a)
CHARACTER*(*) a[reference]
END
C Interface to the atoi function which is in the LIBC library
INTERFACE to INTEGER FUNCTION atoi[C](a)
CHARACTER*(*) a[reference]
END
REAL*8 x
REAL*8 atof !prevents error F2236: ATOF : length redefined
INTEGER i
INTEGER atoi !prevents error F2201: ATOI : type redefined
CHARACTER*30 a
PRINT *, "Type a numeric value"
READ '(A)', a
a(30:30) = char(0)
x = atof(a)
i = atoi(a)
PRINT *, '"',a,'"', x, i
END
Additional query words: kbinf 1.00 1.00a 4.00 VAX porting port
Keywords: kblangfortran kbcode KB120397