FLTK 1.4.5: vsnprintf.c File Reference

FLTK 1.4.5

Loading...
Searching...
No Matches
vsnprintf.c File Reference

Portable vsnprintf() implementation. More...

`#include <stdio.h>`
`#include "flstring.h"`

## Functions
int | fl_snprintf (char *str, size_t size, const char *fmt,...)
int | fl_vsnprintf (char *buffer, size_t bufsize, const char *format, va_list ap)
| FLTK's platform independent wrapper for the vsnprintf() C library function.

## Detailed Description

Portable vsnprintf() implementation.

## Function Documentation

## ◆ fl_vsnprintf()

int fl_vsnprintf | ( | char * | buffer,
|  | size_t | bufsize,
|  | const char * | format,
|  | va_list | ap )

FLTK's platform independent wrapper for the vsnprintf() C library function.

This function guarantees:

- access to vsnprintf(), even on systems that don't have it (FLTK's own built-in code is used)
- Guarantees NUL termination. Even if string expands larger than the buffer, a terminating NUL is included, unlike some implementations of vsnprintf(), notably Microsoft Visual Studio (pre-2015), which can leave the string unterminated when truncated.

If the build environment for FLTK has vsnprintf(), fl_vsnprintf() is just a wrapper around the compiler's provided function. Otherwise, if the function is NOT available, FLTK's own built-in version is provided.

The FLTK built in provides these style options:

- %[ -+#']
- * – padding width
- .* – precision width
- Data types: h, l, ll, L
- Floating point formats: E, G, e, f, g
- Integer formats: B, X, b, d, i, o, u, x
- Pointer format: p
- String/char: c, s, n