StrWriteFmt
Description
Write a formatted string to out from scratch. Equivalent to StrClear(out) followed by StrAppendFmt(out, ...) – any prior contents of out are discarded.
Success
Returns true; out holds exactly the rendered output.
Failure
Returns false if the underlying append fails (allocator failure or invalid format string). out is cleared either way before the append runs, so a failed call leaves out with whatever bytes were appended before the failure. LOG_FATAL if out or the format string is NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Write.c:684:
Str s = StrInit(&alloc);
StrAppendFmt(&s, "old prefix ");
StrWriteFmt(&s, "fresh {}", LVAL(42));
bool ok = (StrLen(&s) == 8) && (StrBegin(&s)[0] == 'f') && (StrBegin(&s)[StrLen(&s) - 1] == '2');
StrDeinit(&s);
Last updated on