remove - C stdio.h

C examples for stdio.h:remove

Type

function

From

<cstdio>
<stdio.h>

Description

Delete a file

Prototype

int remove ( const char * filename );

Parameters

ParameterDescription
filename C string containing the file name.

Return value

On success, a zero value is returned.

On failure, a nonzero value is returned.

Demo Code


#include <stdio.h>

int main ()/* ww  w  .  j  a  v  a  2 s.c om*/
{
  if( remove( "main.cpp" ) != 0 )
    perror( "Error deleting file" );
  else
    puts( "File successfully deleted" );
  return 0;
}

Related Tutorials