News for hackers. Stuff that matters.
Re:Massacring C Pointers by nwmcsween on Tuesday June 26, 2018 @02:56AM (#17398445)
Well to be pedantic C++'s type system doesn't check for that either it just passes around a size_t and char *.
Re:Massacring C Pointers by saagarjha on Tuesday June 26, 2018 @03:06AM (#17398487)
I was referring to std::string, which is what you should be using if you're handling textual data natively.
Re:Massacring C Pointers by nwmcsween on Wednesday June 27, 2018 @04:01AM (#17406511)
The implementation of std::string is 99.999% of the time struct { char *s; size_t len; }, which has nothing to do with an actual type.
Re:Massacring C Pointers by gmueckl on Tuesday June 26, 2018 @07:04AM (#17399498)
And it's even possible to use std::string as a buffer for binary data including NULs. I won't recommend it, but it works.
Re:Massacring C Pointers by saagarjha on Tuesday June 26, 2018 @12:08PM (#17401762)
I'd suggest using a std::vector of byte-sized integers for clarity, though there's nothing wrong from a standards point in using a std::string.