logoalt Hacker News

ueckeryesterday at 9:53 PM2 repliesview on HN

why not std::string?


Replies

teo_zeroyesterday at 10:23 PM

You can surely create a std::string-like type in C, call it "newstring", and write functions that accept and return newstrings, and re-implement the whole standard library to work with newstrings, from printf() onwards. But you'll never have the comfort of newstring literals. The nice syntax with quotes is tied to zero-terminated strings. Of course you can litter your code with preprocessor macros, but it's inelegant and brittle.

show 1 reply
direwolf20yesterday at 10:11 PM

It's a class, so it doesn't work in C.

show 1 reply