<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>kazinator</author><text>&amp;gt; &lt;i&gt;write to fixed size data structures such as part of the filesystem where you don&amp;#x27;t want to store NUL termination on strings&lt;/i&gt;&lt;p&gt;... AND where you want to pad the remaining space with zero bytes, so that you don&amp;#x27;t leak uninitialized memory onto the disk, or network.&lt;p&gt;The null byte padding behavior of strncpy makes it clear what the intended use was.&lt;p&gt;Also, the way C initializes character arrays from literals has strncpy-like behavior, because the entire aggregate is initialized, so the extra bytes are all zero:&lt;p&gt;&lt;pre&gt;&lt;code&gt;   char a[4] = &amp;quot;a&amp;quot;;      &amp;#x2F;&amp;#x2F; like strncpy(a, &amp;quot;a&amp;quot;, 4);
   char b[4] = &amp;quot;abcd&amp;quot;;   &amp;#x2F;&amp;#x2F; like strncpy(a, &amp;quot;abcd&amp;quot;, 4);
&lt;/code&gt;&lt;/pre&gt;
the compiler could literally emit strncpy calls to do these initializations, so we might say that strncpy is a primitive that is directly relevant for run-time support for a C declaration feature.</text><parent_chain><item><author>tialaramex</author><text>Note that strncpy() is &lt;i&gt;not&lt;/i&gt; intended for safety. The purpose of strncpy() is to write to fixed size data structures such as part of the filesystem where you don&amp;#x27;t want to store NUL termination on strings.&lt;p&gt;Like 1980s Internet protocol features the rationale for weird things in C is more often &amp;quot;That&amp;#x27;s how Unix works&amp;quot; than &amp;quot;This is actually a clever safety feature&amp;quot;.</text></item><item><author>Karellen</author><text>The tipping point for me would be `snprintf()` and related functions. I&amp;#x27;ve found it generally more useful&amp;#x2F;memorable&amp;#x2F;readable than strncpy()&amp;#x2F;strlcpy() and other updates to the dangerous and deprecated strcpy() just for copying strings safely, never mind it&amp;#x27;s other formatting abilities.&lt;p&gt;If Curl already has its own &amp;quot;decent and functional replacement&amp;quot; for `snprintf()` that&amp;#x27;s used extensively throughout the codebase, or if they just don&amp;#x27;t need that functionality (I haven&amp;#x27;t checked) then I guess that&amp;#x27;s not an issue. But that would be the big selling point as far as I&amp;#x27;m concerned.</text></item></parent_chain></comment><story><title>Considering C99 for Curl</title><url>https://daniel.haxx.se/blog/2022/11/17/considering-c99-for-curl/</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>kzrdude</author><text>Do we have a source for what the intended purpose is? I think you speak well to the effective purpose, but I&amp;#x27;m not sure if it was that clear when it was introduced.</text><parent_chain><item><author>tialaramex</author><text>Note that strncpy() is &lt;i&gt;not&lt;/i&gt; intended for safety. The purpose of strncpy() is to write to fixed size data structures such as part of the filesystem where you don&amp;#x27;t want to store NUL termination on strings.&lt;p&gt;Like 1980s Internet protocol features the rationale for weird things in C is more often &amp;quot;That&amp;#x27;s how Unix works&amp;quot; than &amp;quot;This is actually a clever safety feature&amp;quot;.</text></item><item><author>Karellen</author><text>The tipping point for me would be `snprintf()` and related functions. I&amp;#x27;ve found it generally more useful&amp;#x2F;memorable&amp;#x2F;readable than strncpy()&amp;#x2F;strlcpy() and other updates to the dangerous and deprecated strcpy() just for copying strings safely, never mind it&amp;#x27;s other formatting abilities.&lt;p&gt;If Curl already has its own &amp;quot;decent and functional replacement&amp;quot; for `snprintf()` that&amp;#x27;s used extensively throughout the codebase, or if they just don&amp;#x27;t need that functionality (I haven&amp;#x27;t checked) then I guess that&amp;#x27;s not an issue. But that would be the big selling point as far as I&amp;#x27;m concerned.</text></item></parent_chain></comment><story><title>Considering C99 for Curl</title><url>https://daniel.haxx.se/blog/2022/11/17/considering-c99-for-curl/</url></story>