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
    1. Advertising

  2. 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
     
    Martin Ambuhl, Jul 4, 2003
    #2
    1. Advertising

  3. Colin

    Mike Wahler Guest

    Colin <> wrote in message
    news:...
    > 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
     
    Mike Wahler, Jul 4, 2003
    #3
  4. 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"?
     
    Peter Shaggy Haywood, Jul 6, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roy Terrazas

    renaming files using asp

    Roy Terrazas, Jul 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    375
    Craig Deelsnyder
    Jul 30, 2003
  2. master007
    Replies:
    8
    Views:
    841
    Oliver Wong
    Mar 6, 2006
  3. Pegboy

    system(), renaming files and long filenames

    Pegboy, Nov 8, 2003, in forum: C Programming
    Replies:
    6
    Views:
    478
    Paul Emmons
    Dec 13, 2003
  4. David Lebel

    regular expressions and renaming files

    David Lebel, Feb 18, 2004, in forum: Python
    Replies:
    0
    Views:
    295
    David Lebel
    Feb 18, 2004
  5. Thierry Lam

    Renaming files in ftplib

    Thierry Lam, Jan 6, 2006, in forum: Python
    Replies:
    2
    Views:
    584
Loading...

Share This Page