Thread: Delete file on linux

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    167

    Delete file on linux

    I need in a program to use a tmp file. I don't know how to delete that file when the program exits.
    How can I do that ?

    Thank you!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Call the remove() function, passing the filename to delete.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    remove() is a system call ?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Location
    Beirut, Lebanon
    Posts
    20
    You have unlink() as a system call.

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by spank View Post
    remove() is a system call ?
    remove() is standard C. It would work on the alien mainframes from Planet Blorn, if they ran C, that is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The best way to delete a record from a file?
    By salvadoravi in forum C Programming
    Replies: 25
    Last Post: 01-28-2008, 01:12 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM