Re: Is there any problem with the following program?



zhngbn wrote:
I find the following program in a book:

program ex0413
character(len=20) string
string = "Good morning."
write(*, *) string
string(6) = "evening."
write(*, *) string
end

When it is complied by CVF, the following error is displayed:
Error: This name has not been declared as an array. [STRING]
string(6) = "evening."
So, can anyone tell me what is the problem? Thanks a lot.

My guess is that the intent was
string(6:13) = "evening."

This looks suspiciously like a g77 program, and g77 will tell you
specifically about the missing colon.
CVF and its relatives are hinting that
character(len=20) string(6)
(an array of 6 strings of length 20)
would permit the usage string(6). Each of your write statements would
display all 6 strings.
.


Quantcast