j****s 发帖数: 1522 | 1 How can I convert an integer to a character in fortran?
For example, IY=1984, 1985, ..., and IY is changable, and I wish the character
YEAR would be 1984, 1985, ..., too, and it could be changed following IY. I
try to use the function achar and char, and they don't work as my expectation.
Actually, my final purpose is to concatenate characters (strings) with integer
and create a new string. Please tell me how I can do. Thanks. | n******s 发帖数: 7 | 2 Try:
character(len=8)::year
integer::iy=1984
write(unit=year,fmt="('ye',i4.4,'ar')")iy
This is like sprintf() in C.
character
expectation.
integer
【在 j****s 的大作中提到】 : How can I convert an integer to a character in fortran? : For example, IY=1984, 1985, ..., and IY is changable, and I wish the character : YEAR would be 1984, 1985, ..., too, and it could be changed following IY. I : try to use the function achar and char, and they don't work as my expectation. : Actually, my final purpose is to concatenate characters (strings) with integer : and create a new string. Please tell me how I can do. Thanks.
|
|