Thread: How to create file with user defined name?

  1. #1
    Registered User
    Join Date
    Feb 2016
    Posts
    14

    How to create file with user defined name?

    I want to make a file using fopen with a user given name eg. -o yeah

    the filename will be yeah. I'm not sure how to do it since if I put fopen("%s",argv[2],"w") it will have too many arguements. Any thoughts?

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,616
    You have to find which argument is the "-o" argument. Let's say it's argument i; that means that 0 < i < argc-1, and you should fopen(argv[i + 1], "w");

  3. #3
    Registered User
    Join Date
    Feb 2016
    Posts
    14

    Thank you!!

    ))

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. User defined output file name help!!!
    By nathank in forum C Programming
    Replies: 4
    Last Post: 05-07-2015, 07:42 AM
  2. File names using a user defined name
    By KnightMan in forum C Programming
    Replies: 2
    Last Post: 04-11-2011, 08:28 PM
  3. user defined file I/O
    By montablac in forum C++ Programming
    Replies: 3
    Last Post: 06-05-2005, 04:26 AM
  4. Opening a user-defined file
    By mr_diss in forum C Programming
    Replies: 8
    Last Post: 02-28-2005, 03:47 PM
  5. Create a matrix with user-defined dimensions
    By EliasK in forum C Programming
    Replies: 2
    Last Post: 04-08-2003, 07:09 AM

Tags for this Thread