docs/Writerside/topics/string.h.md

changeset 1297
0811fb9a8dba
parent 1226
129ef9bb1477
--- a/docs/Writerside/topics/string.h.md	Tue Apr 15 22:16:05 2025 +0200
+++ b/docs/Writerside/topics/string.h.md	Wed Apr 16 20:35:34 2025 +0200
@@ -42,6 +42,10 @@
 void cx_strfree(cxmutstr *str);
 
 void cx_strfree_a(const CxAllocator *alloc, cxmutstr *str);
+
+
+#define CX_SFMT(s)   (int) (s).length, (s).ptr
+#define CX_PRIstr    ".*s"
 ```
 
 The functions `cx_str()` and `cx_mutstr()` create a UCX string from a `const char*` or a `char*`
@@ -57,6 +61,9 @@
 It is safe to call these functions multiple times on a given string, as the pointer will be nulled and the length set to zero.
 It is also safe to call the functions with a `NULL`-pointer, just like any other `free()`-like function.
 
+When you want to use a UCX string in a `printf`-like function, you can use the macro `CX_PRIstr` for the format specifier,
+and the `CX_SFMT(s)` macro to expand the arguments.
+
 > When you want to convert a string _literal_ into a UCX string, you can also use the `CX_STR(lit)` macro.
 > This macro uses the fact that `sizeof(lit)` for a string literal `lit` is always the string length plus one,
 > effectively saving an invocation of `strlen()`.

mercurial