mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Added fmt.ctprint
This commit is contained in:
@@ -373,6 +373,25 @@ caprintfln :: proc(format: string, args: ..any) -> cstring {
|
|||||||
// *Allocates Using Context's Temporary Allocator*
|
// *Allocates Using Context's Temporary Allocator*
|
||||||
//
|
//
|
||||||
// Inputs:
|
// Inputs:
|
||||||
|
// - args: A variadic list of arguments to be formatted.
|
||||||
|
// - sep: An optional separator string (default is a single space).
|
||||||
|
//
|
||||||
|
// Returns: A formatted C string.
|
||||||
|
//
|
||||||
|
@(require_results)
|
||||||
|
ctprint :: proc(args: ..any, sep := " ") -> cstring {
|
||||||
|
str: strings.Builder
|
||||||
|
strings.builder_init(&str, context.temp_allocator)
|
||||||
|
sbprint(&str, ..args, sep=sep)
|
||||||
|
strings.write_byte(&str, 0)
|
||||||
|
s := strings.to_string(str)
|
||||||
|
return cstring(raw_data(s))
|
||||||
|
}
|
||||||
|
// Creates a formatted C string
|
||||||
|
//
|
||||||
|
// *Allocates Using Context's Temporary Allocator*
|
||||||
|
//
|
||||||
|
// Inputs:
|
||||||
// - format: A format string with placeholders for the provided arguments
|
// - format: A format string with placeholders for the provided arguments
|
||||||
// - args: A variadic list of arguments to be formatted
|
// - args: A variadic list of arguments to be formatted
|
||||||
// - newline: Whether the string should end with a newline. (See `ctprintfln`.)
|
// - newline: Whether the string should end with a newline. (See `ctprintfln`.)
|
||||||
|
|||||||
Reference in New Issue
Block a user