[Fortran] 纯文本查看 复制代码
module typedef
Implicit None
type tttt
integer:: num
character(len=15) :: name1
end type tttt
end module typedef
module mod_struct_mod
use typedef
Implicit None
contains
subroutine mod_struct(struct)
type(tttt),pointer:: struct
struct%name1="xie"
end subroutine mod_struct
end module mod_struct_mod
program hello
use mod_struct_mod
type(tttt),pointer::ps
type(tttt),target :: s
s%num=1
s%name1="wangwei"
ps=>s
call mod_struct(ps)
write(*,*) ps
end program hello
[Fortran] 纯文本查看 复制代码
module typedef
type tttt
integer:: num
character(len=15) :: name1
end type tttt
end module typedef
program hello
use typedef
type(tttt),pointer::ps
type(tttt),target :: s
s%num=1
s%name1="wangwei"
ps=>s
!!!我还想对结构体指针利用过程重新赋值,代码如下
call mod_struct(ps)
end program hello
subroutine mod_struct(struct)
use typedef
type(tttt),pointer:: struct
struct%name1="xie"
end