Renaming files in C

C

Colin

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 ?
 
M

Martin Ambuhl

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.
 
M

Mike Wahler

Colin said:
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
 
P

Peter Shaggy Haywood

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"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top