GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
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 * (C) 2001-2014 by the GRASS Development Team
13 *
14 * This program is free software under the GNU General Public License
15 * (>=v2). Read the file COPYING that comes with GRASS for details.
16 *
17 * \author Markus Neteler
18 *
19 * \date 2006-2008
20 */
21
22#include <stdarg.h>
23#include <stdio.h>
24
25#include <grass/gis.h>
26
27/**
28 * \brief snprintf() clone.
29 *
30 * <b>Note:</b> The use of <i>snprintf()</i>/<i>G_snprintf()</i> is
31 * discouraged in favour of calculating how long the string will be and
32 * allocating enough memory!
33 *
34 * \deprecated Use C99 standard function snprintf() instead.
35 *
36 * \param[in] str input string
37 * \param[in] size length of string
38 * \param[in] fmt
39 * \return number of chars written
40 */
41int G_snprintf(char *str, size_t size, const char *fmt, ...)
42{
43 va_list ap;
44 int count;
45
46 va_start(ap, fmt);
47 count = vsnprintf(str, size, fmt, ap);
48 va_end(ap);
49
50 return count;
51}
int count
int G_snprintf(char *str, size_t size, const char *fmt,...)
snprintf() clone.
Definition snprintf.c:41