-
Notifications
You must be signed in to change notification settings - Fork 197
-
Hello,
Is there a stdlib function which allows to convert an integer to a character vector (opposite of ichar if I understand well)?
I mean, something more or less like:
function itoa(i) result(res) !------------------------------------------------------------------------------------------ !! Convert integer to string. !------------------------------------------------------------------------------------------ integer, intent(in) :: i !! Integer character(:), allocatable :: res character(range(i)+2) :: tmp write(tmp,'(i0)') i res = trim(tmp) end function
Thanks for any hint.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
to_string (
https://stdlib.fortran-lang.org/page/specs/stdlib_strings.html#to_string)
is most likely what you are looking for
Le sam. 10 sept. 2022 à 19:18, HugoMVale ***@***.***> a
écrit :
... Hello,
Is there a stdlib function which allows to convert an integer to a
character vector (opposite of ichar if I understand well)?
I mean, something more or less like:
function itoa(i) result(res)
!------------------------------------------------------------------------------------------
!! Convert integer to string.
!------------------------------------------------------------------------------------------
integer, intent(in) :: i
!! Integer
character(:), allocatable :: res
character(range(i)+2) :: tmp
write(tmp,'(i0)') i
res = trim(tmp)
end function
Thanks for any hint.
—
Reply to this email directly, view it on GitHub
<#676>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD5RO7DPT62PJHDVC4ZNETTV5S7H7ANCNFSM6AAAAAAQJNEVHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
Beta Was this translation helpful? Give feedback.
All reactions
1 reply
-
Thanks a lot, @jvdp1. Now that you told me where to search for, I realized that the section Contributing and specs has all the necessary explanations, but I never thought of looking under than title... I searched directly under Modules and Procedures and got lost. Perhaps we could rename Contributing and specs to API reference (as numpy) or similar.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment