Misplaced Pages

Remove (C): Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 17:43, 9 August 2010 edit1exec1 (talk | contribs)Pending changes reviewers, Rollbackers50,085 editsm {← Previous edit Revision as of 17:45, 9 August 2010 edit undo1exec1 (talk | contribs)Pending changes reviewers, Rollbackers50,085 editsm Sample usage: add exampleNext edit →
Line 15: Line 15:


<source lang="c"> <source lang="c">

int main()
#include <stdio.h>

int main() {
const char *filename = "a.txt";
remove (filename);
return 0;
}
</source>

Revision as of 17:45, 9 August 2010

remove is a function in C programming language that removes a certain file. It is included in the C standard library header file stdio.h.

The prototype of the function is as follows:

int remove ( const char * filename );

If successful, the function returns zero. Nonzero value is returned on failure and errno variable is set to corresponding error code.

Sample usage

The following program demonstrates common usage of remove:

#include <stdio.h>
int main() {
    const char *filename = "a.txt";
    remove (filename);
    return 0;
    }