How do I make a program with two arguments in dos

This is a discussion on How do I make a program with two arguments in dos within the C Programming forums, part of the General Programming Boards category; one for a filename to read from the other for a filename to write to?...

  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,531
    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 in reply to you, it is likely you deserve it. Suck it up, sunshine, 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, 01:27 PM
  2. Executing a Program With Arguments
    By HalNineThousand in forum Linux Programming
    Replies: 4
    Last Post: 04-14-2008, 11: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, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21