From 7ef8a7379f7f7d09e71ccae2a0b688c3cd80423f Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 8 Feb 2019 18:42:39 -0500 Subject: merge sources into single tree --- src/stdio/sprintf.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/stdio/sprintf.c (limited to 'src/stdio/sprintf.c') diff --git a/src/stdio/sprintf.c b/src/stdio/sprintf.c new file mode 100644 index 00000000..babd4ba3 --- /dev/null +++ b/src/stdio/sprintf.c @@ -0,0 +1,31 @@ +#include +#include "stdarg.h" +#include "nonstd/io.h" +#include "nonstd/internal.h" + +/** write formatted output to a string **/ +int sprintf(char * restrict s, const char * restrict format, ...) +{ + int ret = 0; + va_list ap; + struct io_options opt = {0}; + opt.fnname = "sprintf"; + opt.string = s; + opt.maxlen = (size_t)-1; + va_start(ap, format); + ret = __printf(&opt, format, ap); + va_end(ap); + /* + RETURN_SUCCESS(the number of characters written to the array, not counting the terminating null); + */ + return ret; +} + +/*** +writes a formatted string to the buffer at ARGUMENT(s). The format of +ARGUMENT(format) and the variadic arguments is the same as that for +FUNCTION(printf). +***/ +/* +STDC(1) +*/ -- cgit v1.2.1