Convert C string to Fortran
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=c_char, len=1), | intent(in), | dimension(:) | :: | cstr |
string from C |
fortran string
function c2f_str(cstr) result(fstr) character(kind=c_char, len=1), dimension(:), intent(in) :: cstr !! string from C character(len=:), allocatable :: fstr !! fortran string integer :: i !! counter fstr = '' do i = 1, size(cstr) fstr = fstr//cstr(i) end do fstr = trim(fstr) end function c2f_str