summaryrefslogtreecommitdiff
path: root/devdocs/c/io%2Fperror.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/io%2Fperror.html')
-rw-r--r--devdocs/c/io%2Fperror.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/devdocs/c/io%2Fperror.html b/devdocs/c/io%2Fperror.html
new file mode 100644
index 00000000..914c9153
--- /dev/null
+++ b/devdocs/c/io%2Fperror.html
@@ -0,0 +1,36 @@
+ <h1 id="firstHeading" class="firstHeading">perror</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;stdio.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td class="t-dcl-nopad"> <pre data-language="c">void perror( const char *s );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>Prints a textual description of the error code currently stored in the system variable <code><a href="../error/errno" title="c/error/errno">errno</a></code> to <code><a href="std_streams" title="c/io/std streams">stderr</a></code>.</p>
+<p>The description is formed by concatenating the following components:</p>
+<ul>
+<li> the contents of the null-terminated byte string pointed to by <code>s</code>, followed by <code>": "</code> (unless <code>s</code> is a null pointer or the character pointed to by <code>s</code> is the null character) </li>
+<li> implementation-defined error message string describing the error code stored in <code>errno</code>, followed by <code>'\n'</code>. The error message string is identical to the result of <code><a href="http://en.cppreference.com/w/c/string/byte/strerror"><span class="kw574">strerror</span></a><span class="br0">(</span><span class="kw2">errno</span><span class="br0">)</span></code>. </li>
+</ul> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> s </td> <td> - </td> <td> pointer to a null-terminated string with explanatory message </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p>(none)</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+
+int main(void)
+{
+ FILE *f = fopen("non_existent", "r");
+ if (f == NULL) {
+ perror("fopen() failed");
+ } else {
+ fclose(f);
+ }
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">fopen() failed: No such file or directory</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.21.10.4 The perror function (p: 339) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.19.10.4 The perror function (p: 305) </li></ul>
+<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
+<ul><li> 4.9.10.4 The perror function </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="../string/byte/strerror" title="c/string/byte/strerror"> <span class="t-lines"><span>strerror</span><span>strerror_s</span><span>strerrorlen_s</span></span></a></div>
+<div><span class="t-lines"><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> returns a text version of a given error code <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/perror" title="cpp/io/c/perror">C++ documentation</a></span> for <code>perror</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/io/perror" class="_attribution-link">https://en.cppreference.com/w/c/io/perror</a>
+ </p>
+</div>