13 июня 2011 г.

int2str and str2num in fortran, How to convert string to integer and vice versa

To convert a number/integer to a string, you need to write the variable into the string character.

Integer I
Character* str
I = 9999
Write( str, '(i10)' ) I
End


To convert a string to number or integer, you need to read the strign and assign it to the integer

Integer I
Character* str
I = 9999
read( str, '(i10)' ) I
End

Взято отсюда.