主题:[讨论]【求助】单链表的问题
program experiment
implicit none
type link
character ::c
type(link),pointer::next
end type link
type(link),pointer::root,current
integer::io_stat_number=0
allocate(root)
read(*,'(A)',advance='no',iostat=io_stat_number)root%c
if(io_stat_number==-1)then
nullify(root%next)
else
allocate(root%next)
endif
current=>root
do while(associated(current%next))
current=>current%next
read(*,'(A)',advance='no',iostat=io_stat_number)current%c
if(io_stat_number==-1)then
nullify(current%next)
else
allocate(current%next)
endif
end do
current=>root
[color=FF0000]do while(associated(current%next))[/color]
print *,current%c
current=>current%next
end do
end program experiment
以上是代码
我的问题是红字处 的意思是不是说如果current%next没有关联循环就不执行
可是最后一个(我理解是最后一个current%next应该是没关联的吧)current%c为什么还能被print呢
implicit none
type link
character ::c
type(link),pointer::next
end type link
type(link),pointer::root,current
integer::io_stat_number=0
allocate(root)
read(*,'(A)',advance='no',iostat=io_stat_number)root%c
if(io_stat_number==-1)then
nullify(root%next)
else
allocate(root%next)
endif
current=>root
do while(associated(current%next))
current=>current%next
read(*,'(A)',advance='no',iostat=io_stat_number)current%c
if(io_stat_number==-1)then
nullify(current%next)
else
allocate(current%next)
endif
end do
current=>root
[color=FF0000]do while(associated(current%next))[/color]
print *,current%c
current=>current%next
end do
end program experiment
以上是代码
我的问题是红字处 的意思是不是说如果current%next没有关联循环就不执行
可是最后一个(我理解是最后一个current%next应该是没关联的吧)current%c为什么还能被print呢