GRASS 8 Programmer's Manual 8.6.0dev(2026)-08f30e8994
Loading...
Searching...
No Matches
snprintf.c
Go to the documentation of this file.
1/*!
2 * \file lib/gis/snprintf.c
3 *
4 * \brief GIS Library - snprintf() clone functions.
5 *
6 *
7 * \todo if needed, implement alternative versions for portability.
8 * potential code source:
9 * - http://www.ijs.si/software/snprintf/
10 * - openssh's snprintf() implementation: bsd-snprintf.c
11 *
12 * SPDX-FileCopyrightText: 2001-2014 GRASS Development Team
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * \author Markus Neteler
16 *
17 * \date 2006-2008
18 */
19
20#include <stdarg.h>
21#include <stdio.h>
22
23#include <grass/gis.h>
24
25/**
26 * \brief snprintf() clone.
27 *
28 * <b>Note:</b> The use of <i>snprintf()</i>/<i>G_snprintf()</i> is
29 * discouraged in favour of calculating how long the string will be and
30 * allocating enough memory!
31 *
32 * \deprecated Use C99 standard function snprintf() instead.
33 *
34 * \param[in] str input string
35 * \param[in] size length of string
36 * \param[in] fmt
37 * \return number of chars written
38 */
39int G_snprintf(char *str, size_t size, const char *fmt, ...)
40{
41 va_list ap;
42 int count;
43
44 va_start(ap, fmt);
45 count = vsnprintf(str, size, fmt, ap);
46 va_end(ap);
47
48 return count;
49}
int count
int G_snprintf(char *str, size_t size, const char *fmt,...)
snprintf() clone.
Definition snprintf.c:39