PDA

View Full Version : [LF] Help! string length known when excuting


Lahey Support
08-15-2003, 12:19 AM
Dear All:

I need to input a string for a code when it excutes, and

the problem is that I have no idea about the string's length

before excuting. Of course, I can declare a very long string

to prepare for it, but that doesn't sound like exciting.

I've try to do this way:

program test
character, pointer :: string(:)
integer :: n, i

...
read(*,*) n
allocate( string(n) )
do i = 1,n
read(*,*) string(:,:)
enddo

write(*,*) string
...
stop
end program test

This, of course, worked, but it works stupid and inconvient... :(

So, is there anyone could help me?


Thank you

by Cheng Cosine
Jan/15/1999 UT


__________________________________________________ ____
Get Your Private, Free Email at http://www.hotmail.com