如何在子例程path
中找到动态分配的对象newcase
的大小?
subroutine newcase(path)
character(:, kind=c_char),
& allocatable :: path
integer(kind=c_int) :: sizepath
write(*,*) "Trim Path: ", path, ":"
this% object = newcase_c(path, sizepath)
end subroutine newcase
在调用子例程时分配对象,如下所示:
character(256, kind=c_char) :: cwd
character(:, kind=c_char)
& , allocatable :: trimpath
call GETCWD(cwd)
trimpath = trim(cwd)
call newcase(trimpath)