GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-1d42e580e2
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
*/
41
42
int
G_snprintf
(
char
*str,
size_t
size,
const
char
*fmt, ...)
43
{
44
va_list ap;
45
int
count
;
46
47
va_start(ap, fmt);
48
count
= vsnprintf(str, size, fmt, ap);
49
va_end(ap);
50
51
return
count
;
52
}
gis.h
count
int count
G_snprintf
int G_snprintf(char *str, size_t size, const char *fmt,...)
snprintf() clone.
Definition:
snprintf.c:42
lib
gis
snprintf.c
Generated on Sat Oct 12 2024 06:58:49 for GRASS GIS 8 Programmer's Manual by
1.9.1