Help a Newbie with Deleting.

This is a discussion on Help a Newbie with Deleting. within the C++ Programming forums, part of the General Programming Boards category; No matter where i look, i can find anywhere that says how to delete files in c++. For instance,i would ...

  1. #1
    unregistered
    Guest

    Unhappy Help a Newbie with Deleting.

    No matter where i look, i can find anywhere that says how to delete files in c++. For instance,i would do.

    --------------------------------------------------

    cout<<"deleteing C:\test\null.txt";
    --------------------------------------------------
    but how do i actually make the program delete it?

    plz reply

    (dont flame please, im 14 yrs old and i know c++, gimme some credit)

  2. #2
    Unregistered
    Guest

    Re: Help a Newbie with Deleting.

    Originally posted by unregistered
    No matter where i look, i can find anywhere that says how to delete files in c++. For instance,i would do.

    --------------------------------------------------

    cout<<"deleteing C:\test\null.txt";
    --------------------------------------------------
    but how do i actually make the program delete it?

    plz reply

    (dont flame please, im 14 yrs old and i know c++, gimme some credit)
    grr damnit, see that part where it says \test\null.txt
    well wouldnt the \n part cuase a line break? grrr
    help plz

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You can use -

    remove(char* path);

    in <cstdio>, but your path will need to be either "C:\\test\\null.txt" or "C:/test/null.txt".

  4. #4
    Unregistered
    Guest
    hmm i dunno what u mean, like whats that char*? all i know is path is the directory. i tried...

    remove (c:\\test\\null.txt);

    that didnt work... could anybody help me?
    what does he mean by the char* part?
    Help!

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    You have to open an ofstream for that particular file before you can remove it.

    Example:

    ofstream temp;
    temp.open(c:\temp\test.txt);

    remove (c:\temp\test.txt);

    temp.close();

    ------------------------

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie Deleting a file
    By Freestyler in forum C Programming
    Replies: 11
    Last Post: 11-28-2005, 03:01 AM
  2. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 02:17 PM
  3. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 08:44 PM
  4. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 03:02 PM
  5. need help deleting a deleting a struct from file
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 05-20-2002, 06:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21