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
xx
contains 'A'yy
contains 'B'zz
contains 'A' Why doesn't zz
contain 'AB'?
The “+” operator with a String acts as a concatenation operator. Whenever you add a String value to a double using the “+” operator, both values are concatenated resulting a String object. In-fact adding a double value to String is the easiest way to convert a double value to Strings.
In Java, String concatenation forms a new String that is the combination of multiple strings.
string concat() method takes only string arguments, if there is any other type is given in arguments then it will raise an error.
Using the “+” operator − It concatenates the other operand to String and returns a String object. You can convert a double value into a String by simply adding it to an empty String using the “+” operator. In-fact it is the easy way to convert a double value to a String.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With