Chapter 8.6

The append() Function

AmazonClosely related to += operator are the append() functions which allow you to append a string, a character array, or a character to a string. They work like += operator but they are more powerful in that they allow you to, for example, append multiple identical characters of the given count.

The first function simply appends s to the invoking object. The second one appends s, starting at index pos and spanning n characters in s. It will not go beyond the end of s if n is too big. The third one appends n’s c. The fourth one appends cs. The fifth one appends the first n characters in cs.