<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The cpp reference manual has a well-written description<br>
<br>
</div>
<div class="elementToProof" style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://cplusplus.com/reference/cstdio/snprintf/" id="LPlnk105674">https://cplusplus.com/reference/cstdio/snprintf/</a></div>
<pre style="margin: 0px;"><div style="text-align: left; text-indent: 0px; margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">int snprintf ( char * s, size_t n, const char * format, ... );</div></pre>
<div class="elementToProof" style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
the content is stored as a <i>C string</i> in the buffer pointed by <i>s</i> (taking
<i>n</i> as the maximum buffer capacity to fill).</div>
<div class="elementToProof" style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; margin: 0px 0px 5px 40px; border-bottom: 1px solid rgb(32, 64, 128); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>Parameters</b></div>
<dl style="font-size: medium; margin: 0px; color: rgb(0, 0, 0); font-family: Roboto, sans-serif;">
<dt style="font-size: 16px; margin: 5px 0px 0px; font-family: Inconsolata, monospace;">
<div style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
s</div>
</dt><dd style="font-size:16px;margin:0px 0px 10px 30px">
<div style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Pointer to a buffer where the resulting C-string is stored.<br>
The buffer should have a size of at least <i>n</i> characters.</div>
</dd><dt style="font-size: 16px; margin: 5px 0px 0px; font-family: Inconsolata, monospace;">
<div style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
n</div>
</dt><dd style="font-size:16px;margin:0px 0px 10px 30px">
<div style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">
<span style="color: rgb(0, 0, 0);">Maximum number of bytes to be used in the buffer.<br>
The generated string has a length of at most <tt style="font-family: Inconsolata, monospace; color: rgb(0, 0, 0);">
<div style="margin-left: 200px;"><span style="color: rgb(0, 0, 0);">n-1</span></div>
</tt>, leaving space for the additional terminating null character.<br>
</span><span style="color: rgb(0, 0, 136);"><a href="https://cplusplus.com/size_t" id="OWA6e3e3471-50e6-e1ca-3695-4db0a6837036" class="OWAAutoLink" style="color: rgb(0, 0, 136); margin: 0px;">size_t</a></span><span style="color: rgb(0, 0, 0);"> is an unsigned
 integral type.</span></div>
</dd></dl>
<div class="elementToProof" style="text-align: left; text-indent: 0px; margin: 0px 0px 5px 40px; border-bottom: 1px solid rgb(32, 64, 128); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
As does the <a href="https://www.gnu.org/software/libc/manual/html_node/Formatted-Output-Functions.html" id="LPlnk">
https://www.gnu.org/software/libc/manual/html_node/Formatted-Output-Functions.html</a></div>
<div class="elementToProof" style="margin-left: 40px; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
The <code>snprintf</code> function is similar to <code>sprintf</code>, except that the
<var style="color:rgb(0, 0, 0);font-family:"Times New Roman";font-size:medium">
<div class="elementToProof" style="margin-left: 120px;">size</div>
</var> argument specifies the maximum number of characters to produce. The trailing null character is counted towards this limit, so you should allocate at least
<var style="color:rgb(0, 0, 0);font-family:"Times New Roman";font-size:medium">
<div class="elementToProof" style="margin-left: 120px;">size</div>
</var> characters for the string <var style="color:rgb(0, 0, 0);font-family:"Times New Roman";font-size:medium">
<div class="elementToProof" style="margin-left: 120px;">s</div>
</var>. If <var style="color:rgb(0, 0, 0);font-family:"Times New Roman";font-size:medium">
<div class="elementToProof" style="margin-left: 120px;">size</div>
</var> is zero, nothing, not even the null byte, shall be written and <var style="color:rgb(0, 0, 0);font-family:"Times New Roman";font-size:medium">
<div class="elementToProof" style="margin-left: 120px;">s</div>
</var> may be a null pointer.<br>
<br>
<br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1">
<div id="LPBorder_GTaHR0cHM6Ly93d3cuZ251Lm9yZy9zb2Z0d2FyZS9saWJjL21hbnVhbC9odG1sX25vZGUvRm9ybWF0dGVkLU91dHB1dC1GdW5jdGlvbnMuaHRtbA.." class="LPBorder197506" style="width: 100%; margin-top: 16px; margin-bottom: 16px; position: relative; max-width: 800px; min-width: 424px;">
<table id="LPContainer197506" role="presentation" style="padding: 12px 36px 12px 12px; width: 100%; border-width: 1px; border-style: solid; border-color: rgb(200, 200, 200); border-radius: 2px;">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td style="width: 100%;">
<div id="LPTitle197506" style="font-size: 21px; font-weight: 300; margin-right: 8px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px;">
<a target="_blank" id="LPUrlAnchor197506" href="https://www.gnu.org/software/libc/manual/html_node/Formatted-Output-Functions.html" style="text-decoration: none; color: var(--themePrimary);">Formatted Output Functions (The GNU C Library)</a></div>
<div id="LPDescription197506" style="font-size: 14px; max-height: 100px; color: rgb(102, 102, 102); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px; margin-right: 8px; overflow: hidden;">
Formatted Output Functions (The GNU C Library)</div>
<div id="LPMetadata197506" style="font-size: 14px; font-weight: 400; color: rgb(166, 166, 166); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif;">
www.gnu.org</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
<br>
</div>
</body>
</html>