Computing.Net > Forums > Unix > Is There a C Code Snippet to Rename

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Is There a C Code Snippet to Rename

Reply to Message Icon

Name: Tina Brant
Date: February 12, 2004 at 12:52:57 Pacific
OS: windows98
CPU/Ram: 64k
Comment:

Can anyone tell me if there is a code snippet in 'C' that will rename a file? So far my program will prompt the user for the existing file name; and then prompt the user for the new file name. I just don't know how to actually make it happen.

Is there a way to use the unix renaming command inside of a C program?

Help!




Sponsored Link
Ads by Google

Response Number 1
Name: Electric Mayhem
Date: February 12, 2004 at 14:26:43 Pacific
Reply:

Just a shot in the dark:
System( )

Why do I say shot in the dark?
I'm not a programmer. I have written 1 program a while back for compressing multiple files individually. Since doing it in a DOS like environment is easiest, I used System( ) to perform the compression on each file. Go to www.programmersheaven.com or .net and try to find more information about it there.

HTH!



0

Response Number 2
Name: Electric Mayhem
Date: February 12, 2004 at 14:45:53 Pacific
Reply:

Quote:
"u can use System, or you can use the API.. creat() read() write() Buffer your info and then write it back out. Look at the man pages for those, and you should find what u need.. it'll be done by the kernel for you. :-)"

- From one of the nice programmers on my Buddy list.


0

Response Number 3
Name: fpmurphy
Date: February 13, 2004 at 07:43:30 Pacific
Reply:

Use the POSIX/SUS API rename(2).
man 2 rename will display the details.

- F


0

Response Number 4
Name: Tina Brant
Date: February 13, 2004 at 09:28:11 Pacific
Reply:

Thank you all for your comments & suggestions. I appreciate your help. I am off to investigate... :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Is There a C Code Snippet to Rename

C shell command to get system IP? www.computing.net/answers/unix/c-shell-command-to-get-system-ip/2642.html

Is there a unix command to do this? www.computing.net/answers/unix/is-there-a-unix-command-to-do-this/7479.html

Looking for a tip on how to find out to which printer is attached a print server that is not working, on a unix network www.computing.net/answers/unix/looking-for-a-tip-on-how-to-find-out-to-which-printer-is-attached-a-print-server-that-is-not-working-on-a-unix-network/16.html