Thread: File manipulation

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    File manipulation

    Ok, so through google, and some information at this site, I have gathered up quite a few things, and am about to set off on a console application. I didn't seem to turn up much about file manipulation...? I found information on remove. This just removes a file though. This will be helpful ( instead of using all system calls *yuck* ), but I was wondering where you could find, or how you do file manipulation in c without using system calls.

    In Visual C++ it would be:

    Code:
    CopyFile("c:\\source\\of\\file.ext", "c:\\destination\\of\\file.ext", NULL);
    DeleteFile("c:\\path\\to\\file.ext"); // remove does this though
    MoveFile("c:\\current\\location.ext, "c:\\new\\location.ext");
    The world is waiting. I must leave you now.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Strictly in ANSI C, you would have to work a bit more:

    >CopyFile("c:\\source\\of\\file.ext", "c:\\destination\\of\\file.ext", NULL);
    Open two files, one for reading and one for writing. The one you read from is the source file and the one you write to is the destination file. Manually transfer the data from one file to the next.

    >MoveFile("c:\\current\\location.ext, "c:\\new\\location.ext");
    Same as above except open the destination file at the new location.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM