興味深いことに、Fortran77で整数を文字列にキャストする方法を見つけようとしていました。私は出くわしましCHAR(I)
たが、これはASCIIインデックスIをその位置の文字に変換します。Fortran77で整数を文字列に単純にキャストする方法はありますか?逆はどうですか?
1 に答える
The Fortran way is to write the value of the integer into a string variable; this operation is known as an internal write. I'm heading out the door now so won't check this, and I have an ethical objection to writing FORTRAN77 or helping anyone else write it, so make no guarantee that the following doesn't contain bits of more modern Fortran.
First declare a character variable to receive the integer
character(len=12) :: int_as_string
then write the integer into it as you would normally write an integer to any other channel such as stdout
write(int_as_string,'(i12.12)') my_int
I expect you'll want to set the format for writing the integer to something that suits you better