Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a file. 2

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
US

I was wondering what the easiest way to delete a file (say a .txt file) is. I have found several examples of creating, reading and writing , but no deletion. Any help would be appreciated.

Thanks.
 
remove(strFileName);
I don't like standard description of this function:
"The remove function causes the file whose name is the string pointed to by strFileName to be no longer accessible by that name."
But this function actually delete files.
(will not work with directories).
 
I think the reason the wording is like that is because it's not the job of C to specify that much about the underlying environment. In other words, it's the operating system's job to implement how this is actually done. It may be that the file isn't actually deleted from disk right away, but that the OS does exactly what the description says: change things in such a way that the file can no longer be accessed by its previous name.

I agree that it's a bit confusing for someone that's just looking to delete a file, but the language definition must be very precise about such things. After all, this is what C tutorial books are for, where you will probably find a looser explanation of functions like remove().

Russ
bobbitts@hotmail.com
 
Thanks, that will work for my application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top