From 61de9c0cb0738e51625b6071a88921fecd591180 Mon Sep 17 00:00:00 2001 From: Marco Paland Date: Thu, 2 Aug 2018 16:39:27 +0200 Subject: chore(readme): update readme --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1cad181..930207f 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,25 @@ int vsnprintf(char* buffer, size_t count, const char* format, va_list va); int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...); ``` - **Due to genaral security reasons it is highly recommended to prefer and use `snprintf` (with the max buffer size as `count` parameter) instead of `sprintf`.** `sprintf` has no buffer limitation, so when needed - use it really with care! +### Streamlike usage +Besides the regular standard `printf()` functions, this module also provides `fctprintf()`, which takes an output function as first parameter to build a streamlike output like `fprintf()`: +```C +// define the output function +void my_stream_output(char character, void* arg) +{ + // opt. evaluate the argument and send the char somewhere +} + +{ + // in your code + void* arg = (void*)100; // this argument is passed to the output function + fctprintf(&my_stream_output, arg, "This is a test: %X", 0xAA); + fctprintf(&my_stream_output, nullptr, "Send to null dev"); +} +``` ## Format specifiers -- cgit v1.2.3