Silverfrost Forums

Welcome to our forums

Array assignment query

8 Mar 2010 3:25 #6091

I was under the impression that 'broadcast' assignment for arrays worked with CHARACTER type variables just like it does for numeric data types. However, in the following program (and using, admittedly, v5.40 rather than v5.50), whilst all the characters in variable astring change their values following the assignment statement, only the first character gets assigned the value char(0); the remainder (somehow) get assigned the value 0x20. Have I been under a false impression or is this behaviour indeed unexpected?

Andy

    program array_setting
    integer, parameter :: elements = 8
    character (len = elements) astring
    astring (:) = char (0)
    stop
    end program array_setting
8 Mar 2010 6:30 #6093

I get the result that I would expect. There is only one character variable rather than an array of characters. So only the first character is set to null. An array of single characters gives the result that you want.

Please login to reply.