Re:Popular Myths about C++, Part 1
by millstone on Tuesday December 09, 2014 @09:19AM
(#8722794)
Right. Also, the C version would be cleaner using the printf family of functions. Idiomatic C would use snprintf and accept a buffer. If you insist on returning a heap-allocated object, you could use asprintf, which is not universal but is common. Either way it's a one-liner.
[ Parent
| on HN ]
Yeah, but as soon as you use snprintf you're throwing performance to the wind.The idiomatic C++ solution should beat it hands down. (gulp)