summaryrefslogtreecommitdiff
path: root/c_remove_function.c
diff options
context:
space:
mode:
authorClay Smith <claysmith158@gmail.com>2023-08-01 01:09:09 -0500
committerClay Smith <claysmith158@gmail.com>2023-08-01 01:09:09 -0500
commit102341d7ae8793c29d44fa416d3b5b797d1eca3e (patch)
tree6df9a5d5ef978dc6809a7d71d50de6e359dae2e7 /c_remove_function.c
First commitHEADmain
Diffstat (limited to 'c_remove_function.c')
-rw-r--r--c_remove_function.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/c_remove_function.c b/c_remove_function.c
new file mode 100644
index 0000000..cb8c2db
--- /dev/null
+++ b/c_remove_function.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <string.h>
+
+int main () {
+ int ret;
+ FILE *fp;
+ char filename[] = "file.txt";
+
+ fp = fopen(filename, "w");
+
+ fprintf(fp, "%s", "This is tutorialspoint.com");
+ fclose(fp);
+
+ ret = remove(filename);
+
+ if(ret == 0) {
+ printf("File deleted successfully");
+ } else {
+ printf("Error: unable to delete the file");
+ }
+
+ return(0);
+}