View source code
Display the source code in std/format.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.format.sformat
Format arguments into buffer buf which must be large enough to hold the result.
char[] sformat(alias fmt, Args...)
(
char[] buf,
Args args
)
if (isSomeString!(typeof(fmt)));
char[] sformat(Char, Args...)
(
scope return char[] buf,
scope const(Char)[] fmt,
Args args
);
Returns
The slice of buf containing the formatted string.
Throws
A RangeError if buf isn't large enough to hold the
formatted string.
A FormatException if the length of args is different
than the number of format specifiers in fmt.
Example
The format string can be checked at compile-time (see format for details):
char[10] buf;
writeln(buf[] .sformat!"foo%s"('C')); // "fooC"
writeln(sformat(buf[], "%s foo", "bar")); // "bar foo"
Authors
Walter Bright, Andrei Alexandrescu, and Kenji Hara
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.