It is also possible to concatenate a character onto the beginning or end of an string. In the following example, we will use concatenation and character arithmetic to output an abecedarian series.
βAbecedarianβ refers to a series or list in which the elements appear in alphabetical order. For example, in Robert McCloskeyβs book Make Way for Ducklings, the names of the ducklings are Jack, Kack, Lack, Mack, Nack, Ouack, Pack and Quack. Here is a loop that outputs these names in order:
Again, be careful to use string concatenation only with strings and not with native C strings. Unfortunately, an expression like letter + "ack" is syntactically legal in C++, although it produces a very strange result, at least in my development environment.
Put together the code below to creater a function greeter that adds βhelloβ and βgoodbyeβ behind and ahead of a message respectively and then prints the new message. Example: greeter("ssup") will print βhello ssup goodbyeβ