Thread: How do I make a program with two arguments in dos

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    150

    How do I make a program with two arguments in dos

    one for a filename to read from the other for a filename to write to?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Look up what arguments the main() function accepts.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    150
    int main ( int argc, char *argv[] )
    the first argument is the filename of the exe
    // We assume argv[1] is a filename to open
    FILE *file = fopen( argv[1], "r" );

    what about the second filename and how do I copy the contents of the first into it regardless of the file type?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Here ... read THIS

    No, really... you need to actually read it, instead of just looking for code to copy.

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    150
    Ok I got it.
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program arguments
    By gth759k in forum C Programming
    Replies: 4
    Last Post: 07-10-2008, 12:27 PM
  2. Executing a Program With Arguments
    By HalNineThousand in forum Linux Programming
    Replies: 4
    Last Post: 04-14-2008, 10:09 AM
  3. Make window in VB but make program in C/C++?
    By Boomba in forum Windows Programming
    Replies: 1
    Last Post: 06-23-2004, 12:29 AM
  4. How To Make The Program Installed In Program Files Folder?
    By javacvb in forum Windows Programming
    Replies: 4
    Last Post: 11-05-2003, 05:33 PM
  5. Replies: 2
    Last Post: 03-25-2002, 05:49 AM