Thread: Removing a file

  1. #1
    Registered User
    Join Date
    Jul 2007

    Removing a file

    I created a program to encrypt/decrypt files. The problem is, it creates a new file for the encryption program.

    Now I want to remove the unencrypted file.

    I tried:
    But it doesn't work. Is there a way to remove a file when you're using a variable as the filename?

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    but your sample has missing parts - so it is hard to decide what is your problem

    1. what type is d.filename? if it is std::string you probably need c_str() to pass const char* to remove
    2. have you closed the file before trying to remove it?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  3. #3
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Banks of the River Styx
    unlink()? (edit: Ah, or remove() Was looking in the wrong section...)

    And note that on most computers, removing a file just removes the links to the data - the actual data itself is not cleared until something else overwrites it.
    Last edited by Cactus_Hugger; 02-24-2008 at 01:11 PM.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  4. #4
    Registered User
    Join Date
    Jul 2007
    Thanks vart. I got it to work:

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM