Delete file on linux

This is a discussion on Delete file on linux within the Linux Programming forums, part of the Platform Specific Boards category; I need in a program to use a tmp file. I don't know how to delete that file when the ...

  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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    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, 12:12 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04: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

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