Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is remove in C?

Sheza Munir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The remove function deletes the file with the filename given as a parameter. This is depicted below:

Library

The function is accessible via the stdio.h library.

Parameters

A string containing the name of the file to be deleted is given as a parameter.

Syntax

int remove(const char* filename)

Return values

On successful execution, the function returns 0. Otherwise, a non-zero number is returned.

Code

main.c
this_file.txt
#include <stdio.h>
#include <string.h>
int main() {
int ret;
char filename[] = "this_file.txt"; // name of the file to be deleted
ret = remove(filename); // call the remove function
if(ret == 0) //succesful deletion
{
printf("The file was deleted.");
}
else // unsuccessful deletion
{
printf("Unable to delete file.");
}
}

RELATED TAGS

c

CONTRIBUTOR

Sheza Munir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring