Sunday, July 12, 2009

In my c program i can't do any remove or rename to file is it because i openit and close in each function?

or what is prevent the rename and remove


i include fstream

In my c program i can't do any remove or rename to file is it because i openit and close in each function?
Of course yo can't.


Every file in C:\program files is very important to your computer and some of them are still running.


Trying to remove or rename them will let your computer get crash easily.


If you just want to remove the program you don't want, simply go to "add or remove program" to remove it. Don't even try to rename a file in the directory, or c:\Windows or C:\ Documents and Settings.
Reply:you can try using a system call() or you could copy the file and then paste it into a new one. you could try using this line as well:





include %26lt;stdio.h%26gt;


int rename( const char *oldfname, const char *newfname );





The function rename() changes the name of the file oldfname to newfname. The return value of rename() is zero upon success, non-zero on error.





And to the guy above me she didn't ask for you to do the problem she just wanted to know why she wasn't able to rename or remove files before you call people lazy she did take the time to enter it into yahoo answer to get help do you actually believe she just sat there and waited for a response?


idiot
Reply:There is no rename/remove in fstream. And if you include fstream, that means you are in C++, not C. Do you not even know what language you are programming in? Doesn't matter in the end.





Renaming and removing files is an OS dependent action. Perhaps the simplest thing you could do is issue a system() call with the appropriate rename/delete commands. The more efficient way, but you seem incapable of accomplishing this, is to include the OS specific header files and use the API to rename and delete. You can find out how through MSDN for Windows, and the man pages for Linux.





If you were looking for people to do your homework for you, don't bother. Seriously, don't. No real programmer will have pity on you. We all our work-oriented people. If you're too lazy to Google and try things on your own, we'll leave you to your imminent failure.
Reply:You can't rename or remove file if it is open. File should be closed before such operations.

artificial flowers

No comments:

Post a Comment