blob: 364c8139b0e0c23c18df3165f22805dcc1d88a03 [file]
<html lang="en">
<head>
<title>strncpy - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Strings.html#Strings" title="Strings">
<link rel="prev" href="strncmp.html#strncmp" title="strncmp">
<link rel="next" href="strnlen.html#strnlen" title="strnlen">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="strncpy"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="strnlen.html#strnlen">strnlen</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="strncmp.html#strncmp">strncmp</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Strings.html#Strings">Strings</a>
<hr>
</div>
<h3 class="section">5.31 <code>strncpy</code>&mdash;counted copy string</h3>
<p><a name="index-strncpy-399"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;string.h&gt;
char *strncpy(char *restrict <var>dst</var>, const char *restrict <var>src</var>,
size_t <var>length</var>);
</pre>
<p><strong>Description</strong><br>
<code>strncpy</code> copies not more than <var>length</var> characters from the
the string pointed to by <var>src</var> (including the terminating
null character) to the array pointed to by <var>dst</var>. If the
string pointed to by <var>src</var> is shorter than <var>length</var>
characters, null characters are appended to the destination
array until a total of <var>length</var> characters have been
written.
<p><br>
<strong>Returns</strong><br>
This function returns the initial value of <var>dst</var>.
<p><br>
<strong>Portability</strong><br>
<code>strncpy</code> is ANSI C.
<p><code>strncpy</code> requires no supporting OS subroutines.
<p><br>
</body></html>