Remix.run Logo
uecker 2 hours ago

why not std::string?

teo_zero an hour ago | parent | next [-]

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.

direwolf20 2 hours ago | parent | prev [-]

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

uecker an hour ago | parent [-]

Sure, but you can have a similar string abstraction in C. What would you miss? The overloaded operators?