LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-13-2005, 04:33 AM   #1
monil
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Rep: Reputation: 0
Deleting files in C


Hi,

Is it possible to delete files in the current working directory from c ?

is there any finction like file_delete() that deletes a file?

Pls help

-Monil
 
Old 03-13-2005, 04:40 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282

Rep: Reputation: 61
Of course:
int unlink(const char *pathname);
or
int remove(const char *pathname);

man 2 unlink
man 3 remove

Last edited by keefaz; 03-13-2005 at 04:42 AM.
 
Old 03-13-2005, 09:31 AM   #3
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
however, those are unportable (at least they're not ANSI compliant--but they're probably posixly correct); a `remedy' for that would be to wrap it up in a fuction that makes the appropriate call; then it's easier to change if you want to port it.
 
Old 03-13-2005, 10:24 AM   #4
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
remove() is ISO C. unlink() is not.
 
Old 03-13-2005, 10:33 AM   #5
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
sorry; my bad.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting files from ntfs obscure-shadow Linux - Software 7 06-29-2005 01:01 AM
recovering deleting files scarr3d Debian 1 03-12-2005 07:27 PM
Deleting files! a_priebe47 Slackware 6 10-17-2004 09:58 PM
Deleting files ShakyJake Linux - Newbie 12 05-08-2003 03:07 PM
Deleting files Tingle Linux - Newbie 4 01-16-2003 04:19 PM


All times are GMT -5. The time now is 04:41 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration