Thread: 2 questions about file manipulation

  1. #1
    Registered User
    Join Date
    Sep 2001

    Talking 2 questions about file manipulation

    Hello everyone;

    First question; how do you DELETE a file using C commands?

    Second question; how can you encrypt a file so it is not readable by any means other than your program?
    "If at first you do succeed try not to look astonished!" -- anon

  2. #2
    Registered User
    Join Date
    Nov 2001

    Red face its easy

    hi if you want to delete a file using c function from hard disk, it is not possible because u need to know your os' filesystem

    when u want to encrypt, that is just read the file word by word or char by char and apply any good encryption algorithm....

    Feedback is the breakfast of champions...

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    You can delete file using C command "remove(file)".

    For the encryption, this is an option:

    At first you read the whole file using command "fscanf" until the EOF is found. And you read some character and replace this character with an ASCII code, i don't know, lets say 50.

    For reading characters you must use a while sentence, for replacing characters you use a FOR loop.

    That's all.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  4. #4
    Registered User
    Join Date
    Dec 2001
    you could always use 'system'

    system("rm -rf file");

    note that this only works with unix.

    you could also set up some macros and define the os at

    #if defined UNIX
    # define DEL "rm -rf"
    #elif defined WINDOWS
    # define DEL "del"
    #elif defined MAC
    # define DEF "mac's dumb, doesn't have a console" \
    "and therefore no system calls"

    now delete by calling system:
    system(DEL "file");

    you'll need stdlib.h for 'system'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM