Renaming files in C

Discussion in 'C Programming' started by Colin, Jul 4, 2003.

  1. Colin

    Colin Guest

    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 ?
    Colin, Jul 4, 2003
    1. Advertisements

  2. rename() uses the names of the files. There need not be a FILE * or
    system() in sight.
    Martin Ambuhl, Jul 4, 2003
    1. Advertisements

  3. Colin

    Mike Wahler Guest

    Well, there's a function in the C standard library for
    this --- called, [surprise!] 'rename()'. Look it up.
    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 Wahler, Jul 4, 2003
  4. Groovy hepcat Colin was jivin' on 3 Jul 2003 19:19:12 -0700 in
    Renaming files in C's a cool scene! Dig it!
    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!
    "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"?
    Peter Shaggy Haywood, Jul 6, 2003
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.