Concatenation of two lines does not work

I have the following code, but it does not work:

CHARACTER*260 xx, yy, zz xx = 'A' yy = 'B' zz = xx // yy 

When I debug my code in Visual Studio,

  • variable xx contains 'A'
  • variable yy contains 'B'
  • variable zz contains 'A'

Why does zz not contain "AB"?

+6
source share
1 answer

You defined xx 260 characters long. Assigning a shorter character literal will fill in spaces. So xx contains A and 259 spaces. yy contains B and 259 spaces. Thus, the concatenated string will be 'A' + 259 spaces + 'B' + 259 spaces, a total of 520 characters.

Since zz is only 260 characters long, the rest is truncated.

What you are trying to do is achieved

 zz = trim(xx) // trim(yy) 

trim() removes trailing spaces from lines.

+18
source

Source: https://habr.com/ru/post/989997/


All Articles