summaryrefslogtreecommitdiff
path: root/devdocs/c/io%2Fremove.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/io%2Fremove.html')
-rw-r--r--devdocs/c/io%2Fremove.html61
1 files changed, 61 insertions, 0 deletions
diff --git a/devdocs/c/io%2Fremove.html b/devdocs/c/io%2Fremove.html
new file mode 100644
index 00000000..5813a48f
--- /dev/null
+++ b/devdocs/c/io%2Fremove.html
@@ -0,0 +1,61 @@
+ <h1 id="firstHeading" class="firstHeading">remove</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">int remove( const char* fname );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>Deletes the file identified by character string pointed to by <code>fname</code>.</p>
+<p>If the file is currently open by this or another process, the behavior of this function is implementation-defined (in particular, POSIX systems unlink the file name although the file system space is not reclaimed until the last running process closes the file; Windows does not allow the file to be deleted).</p>
+<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> fname </td> <td> - </td> <td> pointer to a null-terminated string containing the path identifying the file to delete </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p><code>​0​</code> upon success or non-zero value on error.</p>
+<h3 id="Notes"> Notes</h3> <p><a rel="nofollow" class="external text" href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/remove.html">POSIX specifies</a> many additional details for the behavior of this function.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+
+int main(void)
+{
+ FILE* fp = fopen("file1.txt", "w"); // create file
+ if (!fp)
+ {
+ perror("file1.txt");
+ return EXIT_FAILURE;
+ }
+ puts("Created file1.txt");
+ fclose(fp);
+
+ int rc = remove("file1.txt");
+ if (rc)
+ {
+ perror("remove");
+ return EXIT_FAILURE;
+ }
+ puts("Removed file1.txt");
+
+ fp = fopen("file1.txt", "r"); // Failure: file does not exist
+ if (!fp)
+ perror("Opening removed file failed");
+
+ rc = remove("file1.txt"); // Failure: file does not exist
+ if (rc)
+ perror("Double-remove failed");
+
+ return EXIT_SUCCESS;
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">Created file1.txt
+Removed file1.txt
+Opening removed file failed: No such file or directory
+Double-remove failed: No such file or directory</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C23 standard (ISO/IEC 9899:2023): </li>
+<ul><li> 7.21.4.1 The remove function (p: TBD) </li></ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.21.4.1 The remove function (p: TBD) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.21.4.1 The remove function (p: 302) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.19.4.1 The remove function (p: 268) </li></ul>
+<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
+<ul><li> 4.9.4.1 The remove function </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="rename" title="c/io/rename"> <span class="t-lines"><span>rename</span></span></a></div> </td> <td> renames a file <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/remove" title="cpp/io/c/remove">C++ documentation</a></span> for <code>remove</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/remove" class="_attribution-link">https://en.cppreference.com/w/c/io/remove</a>
+ </p>
+</div>