Convert a Fortran string type to a C character array
Version: experimental
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_type), | intent(in) | :: | value |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| integer, | private | :: | lv |
pure function to_c_char_from_string(value) result(cstr) type(string_type), intent(in) :: value character(kind=c_char) :: cstr(slen(value) + 1) integer :: i, lv lv = slen(value) do i = 1, lv cstr(i) = char(value, pos=i) end do cstr(lv + 1) = c_null_char end function to_c_char_from_string