This question already has an answer here:
I have the following code, but it doesn't work:
CHARACTER*260 xx, yy, zz
xx = 'A'
yy = 'B'
zz = xx // yy
When I debug my code in Visual Studio the
- variable
xxcontains 'A' - variable
yycontains 'B' - variable
zzcontains 'A'
Why doesn't zz contain 'AB'?
Alexander Vogt
You defined xx to be 260 characters long. Assigning a shorter character literal will result in a padding with blanks. Thus, xx contains A and 259 blanks. yy contains B and 259 blanks. So the concatenated string would be 'A' + 259 blanks + 'B' + 259 blanks, in total 520 characters.
Since zz is only 260 characters long, the rest is cropped.
What you are trying to do is achieved by
zz = trim(xx) // trim(yy)
trim() removes trailing whitespace from strings.
来源:https://stackoverflow.com/questions/31134182/concatenation-of-two-strings-does-not-work