How to 'deletel a file w/ g++

How do I delete this file

I don't want to end up with an 0byte file
here is what i have now
#include <fstream.h>
int main()
{fstream tmpfile;
 tmpfile.open(RunName,ios::in|ios::out);
 tmpfile.deletedammit!();
 tmpfile.Please?();
}
LVL 2
RuskAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
Standard C++ does not provide and mechanism for deleting files because standard C++ is OS independant and any such mechanism would be OS dependant (because some OS's support directories, some don't, some support 8.3 file names, some support longer ones, some support security etc.).  

 However al operating systems will provide a mechanism to do this.  What operating system are you running on?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RuskAuthor Commented:
I'm running on Unix do you have any idea on how to do this on unix?
0
RuskAuthor Commented:
for other readers:

#include <stdio.h>
#include <fstream.h>

int main()
{fstream tmpfile;
 tmpfile.open(RunName,ios::in|ios::out);
 Remove(RunName);
}
works fine

0
nietodCommented:
Remove() is probably a procedure from the run-time library you are using.  This is a non-standard procedure, so it will (probably) not be supported by all compilers on UNIX.   I believe the OS command to delete a file in UNIX is called unlink().  That should be supported by all compilers on UNIX.  You can use either, but just be aware that remove() may not be available if you change compilers.   And neither will be available if you change platforms.  (If there is any chance of either of these events, then you should consider writting your own delete procedure, that calls upon remove() or unlink().  Then use this procedure throughout your code.  Then if you change compilers/platforms, you just need to change the code inside this procedure, you don't need to change the code anywhere else in the program.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.