Output-Range and char
Jonathan Marler via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 23 10:50:48 PDT 2017
On Sunday, 23 April 2017 at 11:17:37 UTC, Mafi wrote:
> Hi there,
> every time I want to use output-ranges again they seem to be
> broken in a different way (e.g. value/reference semantics).
> This time it is char types and encoding.
>
> [...]
Use sformat:
import std.format, std.stdio;
void main() {
char[20] buffer;
sformat(buffer, "Long string %s\n", "more more more");
write(buffer);
}
Note: the buffer is not large enough to hold the entire string in
your example so this will cause a stack buffer overflow.
More information about the Digitalmars-d-learn
mailing list