.TH gcvt() "" "" "General Function (libc)"
.PC "Convert floating-point numbers to strings"
\fBchar *\fR
\fBgcvt(\fId\^\fB, \fIprec\^\fB, \fIbuffer\^\fB)\fR
\fBdouble \fId\^\fB; int \fIprec\^\fB; char *\fIbuffer\^\fB;\fR
.PP
.B gcvt()
converts floating-point number
.I d
into a NUL-terminated string.
Its operation resembles that of \fBprintf()\fR's operator
.BR %g .
.PP
Argument
.I prec
gives the precision of the string
i.e., the number of numerals to the right of the decimal point.
Unlike its cousins \fBecvt()\fR and \fBfcvt()\fR, \fBgcvt()\fR uses a
buffer that is defined by the caller.
.I buffer
must point to a buffer large enough to hold the result;
64 characters will always be sufficient.
When generating its output,
.B gcvt()
mimics
.B fcvt()
if possible.
Otherwise, it mimics
.BR ecvt() .
.PP
.B gcvt
returns
.IR buffer .
.SH Example
For an example of this function, see the entry for
.BR ecvt() .
.SH "See Also"
.Xr "libc" libc
