What's the most straightforward way to write to stdout using a character array? I want to output a slice of a much larger array, and the slice is not null-terminated. I want to avoid copying the slice to a "proper" null-terminated c-string.
There is a pretty obvious solution I didn't find at first. std::cout
is an instance of ostream
.
void WriteChunk(char *buffer, size_t startpos, size_t length) {
std::cout.write(buffer + startpos, length);
}
so std::cout.write
does the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With