Quote:Original post by Lode
What were the developers of C smoking when they decided not to add useful strings to the language and do they realise what they have caused still 30 years later?
The thing is, when C was invented, it might as well have targeted machines with, I dunno, 1024 BYTES of working memory.
Implementing strings that might was up to half the string's size memory could be considered.... obscene.
Things seem retarded today, when you just do "Hello" + "World" + "!!", and dozens of string buffers and heap allocations get thrown around in there somewhere, in the nice 64-bit OS with exabytes of memory.
But it wasn't so long ago, that individual bytes really mattered. Overlays and 64k/640k boundary anyone?
Quote:const char* test()
{
std::string s = "hallo";
s += "!!";
return s.c_str();
}
And since we are talking about "what were they smoking":
<clippy>It looks like you are trying to concatenate two strings. Would you like to use
strcat</clippy>.