4 ms·
>And the simple ability to concatenate strings without first reserving space for the result Not exactly the same thing, but routine string manipulation in C ge
by xamuel 11y ago
>And the simple ability to concatenate strings without first reserving space for the result
Not exactly the same thing, but routine string manipulation in C gets considerably easier once you discover a highly underrated function called asprintf (basically combines sprintf and malloc, calculating the buffer size for you).
- Elrac 11y agoWoo hoo, thanks for the tip! But I still need to worry about creating a memory leak with this. :(
- Merovius 11y agoAlso, asprintf is a GNU-extension, so if you want to write portable code, it's a no-go (as for everything usefull in C).
- Elrac 11y agoThankfully, I'm not doing much C any more. Those hoity-toity hand-holding languages have spoiled me, and now I don't want to be bothered about memory management and other "trivia." :)
- pjmlp 11y agoNot in ANSI C nor POSIX.