Thread: reading in command line arguments from a file?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > printf(arg) looks just like the txt file,this is a good thing
    If Dave were here he would point out this: http://en.wikipedia.org/wiki/Format_string_attack

    If I understand you correctly, you know how to read from files, you just want to store the switches from the file in argv[]. Then:
    1. Parse the file for switches, storing them in a temporary string.
    2. argc equals how many switches there were.
    3. for each switch s to argc, use strncpy to put the switch in argv[s]
    Last edited by whiteflags; 06-21-2006 at 07:42 PM. Reason: completeness

  2. #2
    Registered User
    Join Date
    Jun 2006
    Posts
    28
    I thank you for pointing that vulnerability out...but I am using printf() only to see that the char arg[] has been loaded with the info from the txt file and I am NOT using it in the code ,only for testing purposes.

    and you are correct, that is what I need to do just not to sure on how to do it.

    an example ,if it's ! to lengthy,would be great.
    Last edited by g1i7ch; 06-21-2006 at 08:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM