This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

remove

Prototype

#include <stdio.h>

int remove(const char *filename);

Description

Removes the specified filename file and returns zero if the operation succeeds, nonzero if it fails.

Example

View source
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*
 * rm.c: remove the specified files.
 * usage: rm <filename>...
 */
int main(int argc, char **argv)
{
    const char *program_name = argv[0];

    if (argc < 2) {
	fprintf(stderr, "usage: %s <filename>...\n", program_name);
	return EXIT_FAILURE;
    }

    while (--argc > 0)
	if (remove(*++argv) != 0) {
	    fprintf(stderr, "%s:%s: %s\n", program_name, *argv,
		    strerror(errno));
	    return EXIT_FAILURE;
	}

    return EXIT_SUCCESS;
}

References

ISO C 9899:1990 7.9.4.1