Re: Conversion from int to char



fm2766 schrieb:
Hello, I have to convert integers in characters; for example: from number i=123456 to string c="123456".
I could write in a file the variable "i", and later read it as a variable "c", but this method seems to me very inefficient.
Some suggestions?

First, declare a character variable which is long enough to hold your bigest integer number:

character(len=15):: iBuf

Second, use the write-statement performing an internal write to the character variable:

write(unit=iBuf, fmt=*) i

If needed, do something for adjusting the characters:

iBuf = adjustl(iBuf)

If you have some docs for the used compiler by hand, you will find this feature under internal write statement. Hope, this helps,

Sebastian.
.