How to delete a file from a specific path in C ++

0

I'm working on Windows and I want to know how to delete a file with a path such as:

C:\Users\Mario\Desktop\texto.txt

I have tried to eliminate it in the following way

remove(C:\Users\Mario\Desktop\texto.txt)

But it marks me wrong

How can I do it?

    
asked by Marco Leslie 02.11.2017 в 00:40
source

1 answer

1

To establish the path of the file to be removed, you must do it this way:

remove("C:\Users\Mario\Desktop\texto.txt")

Remember that the parameter is a string that indicates the path of the file to be deleted, check the documentation of remove () .

You can check to print if the file was successfully deleted or not.

 if(remove("C:\Users\Mario\Desktop\texto.txt") != 0 )
    perror("Error al borrar archivo!.");
  else
    puts("El archivo se borro con exito!");
  return 0; 
    
answered by 02.11.2017 / 01:33
source