Convert a C string to a Fortran string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | c |
C string |
Fortran string
function c2f_string(c) result(f) character(len=*),intent(in) :: c !! C string character(len=:),allocatable :: f !! Fortran string integer :: i i = index(c,c_null_char) if (i<=0) then f = c else if (i==1) then f = '' else if (i>1) then f = c(1:i-1) end if end function c2f_string