C's Biggest Mistake on Hacker News

Paulo Pinto pjmlp at progtools.org
Thu Jul 26 06:04:33 UTC 2018


On Wednesday, 25 July 2018 at 21:16:40 UTC, Walter Bright wrote:
> On 7/24/2018 4:53 AM, Ecstatic Coder wrote:
>>      str = str1 + " " + str2;
>
> But you have to be careful how it is written:
>
>     str = "hello" + "world";
>     str = "hello" + "world" + str1;
>
> don't work, etc.

Well, like everything in C++, there is always a way.

      str = "hello"s + "world";
      str = "hello"s + "world" + str1;

Spot the difference. :)


More information about the Digitalmars-d mailing list