By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,515 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,515 IT Pros & Developers. It's quick & easy.

Renaming files in C

P: n/a
I have two files and I want to rename file B to file A
without doing a system call - can I do this in C using file pointers ?
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 03 Jul 2003, you wrote in comp.lang.c:
I have two files and I want to rename file B to file A
without doing a system call - can I do this in C using file
pointers ?


rename() uses the names of the files. There need not be a FILE * or
system() in sight.
--
Martin Ambuhl
Returning soon to the
Fourth Largest City in America
Nov 13 '05 #2

P: n/a

Colin <co*******@bigpond.com> wrote in message
news:bd**************************@posting.google.c om...
I have two files and I want to rename file B to file A
Well, there's a function in the C standard library for
this --- called, [surprise!] 'rename()'. Look it up.
without doing a system call - can I do this in C using file pointers ?


No 'file pointers' are needed, nor does the file even
need to be opened by you. 'rename()'s parameters are
both strings -- one the 'old' name, the other the 'new' one.
Be sure to check the return value to see if it succeeded
or not.

-Mike

Nov 13 '05 #3

P: n/a
Groovy hepcat Colin was jivin' on 3 Jul 2003 19:19:12 -0700 in
comp.lang.c.
Renaming files in C's a cool scene! Dig it!
I have two files and I want to rename file B to file A
without doing a system call - can I do this in C using file pointers ?


There is the standard C function rename() to perform this very task.
Next time, why not try your C book first?

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.