This repository has been archived on 2023-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
bl_mcu_sdk/components/libc/snprintf.c

27 lines
569 B
C
Raw Normal View History

#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
/**
* This function will fill a formatted string to buffer.
*
* @param buf is the buffer to save formatted string.
*
* @param size is the size of buffer.
*
* @param fmt is the format parameters.
*
* @return The number of characters actually written to buffer.
*/
int snprintf(char *__restrict buf, size_t size, const char *__restrict fmt, ...)
{
int n;
va_list args;
va_start(args, fmt);
n = vsnprintf(buf, size, fmt, args);
va_end(args);
return n;
}