aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-08-02 16:39:27 +0200
committerMarco Paland <marco@paland.com>2018-08-02 16:39:27 +0200
commit61de9c0cb0738e51625b6071a88921fecd591180 (patch)
tree611d519d4282c3f940cc91e6278e41773c7d5101
parentdeb685e7a9f15cec3a7156454ecdc282097c89e7 (diff)
downloadprintf-61de9c0cb0738e51625b6071a88921fecd591180.tar.gz
printf-61de9c0cb0738e51625b6071a88921fecd591180.tar.bz2
printf-61de9c0cb0738e51625b6071a88921fecd591180.zip
chore(readme): update readme
-rw-r--r--README.md17
1 files changed, 16 insertions, 1 deletions
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