diff options
Diffstat (limited to 'devdocs/c/io%2Ffputs.html')
| -rw-r--r-- | devdocs/c/io%2Ffputs.html | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/devdocs/c/io%2Ffputs.html b/devdocs/c/io%2Ffputs.html new file mode 100644 index 00000000..99726ec7 --- /dev/null +++ b/devdocs/c/io%2Ffputs.html @@ -0,0 +1,38 @@ + <h1 id="firstHeading" class="firstHeading">fputs</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><stdio.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-until-c99"> <td> <pre data-language="c">int fputs( const char *str, FILE *stream );</pre> +</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-until-c99">(until C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">int fputs( const char *restrict str, FILE *restrict stream );</pre> +</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <p>Writes every character from the null-terminated string <code>str</code> to the output stream <code>stream</code>, as if by repeatedly executing <code><a href="fputc" title="c/io/fputc">fputc</a></code>.</p> +<p>The terminating null character from <code>str</code> is not written.</p> +<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> str </td> <td> - </td> <td> null-terminated character string to be written </td> +</tr> <tr class="t-par"> <td> stream </td> <td> - </td> <td> output stream </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>On success, returns a non-negative value</p> +<p>On failure, returns <code><a href="../io" title="c/io">EOF</a></code> and sets the <i>error</i> indicator (see <code><a href="ferror" title="c/io/ferror">ferror()</a></code>) on <code>stream</code>.</p> +<h3 id="Notes"> Notes</h3> <p>The related function <code><a href="puts" title="c/io/puts">puts</a></code> appends a newline character to the output, while <code>fputs</code> writes the string unmodified.</p> +<p>Different implementations return different non-negative numbers: some return the last character written, some return the number of characters written (or INT_MAX if the string was longer than that), some simply return a non-negative constant such as zero.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> + +int main(void) +{ + int rc = fputs("Hello World", stdout); + + if (rc == EOF) + perror("fputs()"); // POSIX requires that errno is set +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">Hello World</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul><li> 7.21.7.4 The fputs function (p: 331-332) </li></ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul><li> 7.19.7.4 The fputs function (p: 297) </li></ul> +<li> C89/C90 standard (ISO/IEC 9899:1990): </li> +<ul><li> 4.9.7.4 The fputs function </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="fprintf" title="c/io/fprintf"> <span class="t-lines"><span>printf</span><span>fprintf</span><span>sprintf</span><span>snprintf</span><span>printf_s</span><span>fprintf_s</span><span>sprintf_s</span><span>snprintf_s</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> prints formatted output to <code><a href="std_streams" title="c/io/std streams">stdout</a></code>, a file stream or a buffer <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="puts" title="c/io/puts"> <span class="t-lines"><span>puts</span></span></a></div> </td> <td> writes a character string to <code><a href="std_streams" title="c/io/std streams">stdout</a></code> <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="fgets" title="c/io/fgets"> <span class="t-lines"><span>fgets</span></span></a></div> </td> <td> gets a character string from a file stream <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/io/c/fputs" title="cpp/io/c/fputs">C++ documentation</a></span> for <code>fputs</code> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/io/fputs" class="_attribution-link">https://en.cppreference.com/w/c/io/fputs</a> + </p> +</div> |
