Thread: simple code question

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    4

    simple code question

    i need to write a program to move files from one folder to another how do I "cut and paste" in c

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    This sounds like a job for the OS. If you have to do it in C, have the OS do it with system() calls.

    If you're bored, you can always read in a file, and write it out again somewhere else.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Or, if it's for Windows only, use MoveFile.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    4
    can someone give me a quick sample code that uses movefile, I'm not sure on the syntax

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    ... MoveFile("C:\\from\\here.txt", "C:\\to\\here.txt");

    Seriously, doesn't get much easier

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    4
    thanx a bunch

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    4
    should the code look like this
    Code:
    void main()
    {
    	BOOL movefile("C:\\stuff","C:\\stuff2");
    }
    sry im a real noob
    Last edited by potatopuff; 07-14-2008 at 08:15 PM.

  8. #8
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    it should be
    int main(void) - read FAQ

    BOOL has no meaning in this context
    C is caseSensetive - so movefile and MoveFile are 2 different functions
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in simple code.
    By richdb in forum C Programming
    Replies: 6
    Last Post: 03-20-2006, 02:45 AM
  2. Hopefully simple question, input streams
    By dpro in forum C++ Programming
    Replies: 7
    Last Post: 03-09-2006, 01:59 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Large code Simple Question need help
    By gamer4life687 in forum C++ Programming
    Replies: 5
    Last Post: 10-25-2002, 07:55 PM
  5. simple input and string manipulation question
    By Stig in forum C Programming
    Replies: 1
    Last Post: 12-15-2001, 01:33 PM