Thread: Issue reading program arguments

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,128
    Quote Originally Posted by awsdert View Post
    You realise getopt() & getopt_long() probably also have similarly complex code right? Mine just happens to be in full view, whereas the other 2 you have to hunt it down on the net
    So are printf(), scanf() and many other Standard Library functions that you would rather use than rewrite from scratch! Getopt() and getopt_long() are frameworks written, debugged, and proven, that you just use. I don't have to "Hunt down" the actual code, I just use it!

    I don't want to spend vast amounts of time hard coding Command Line Argument options, and other non-option arguments, or end up with 175 lines of complicated code. How much work will it take to Add/Change/Delete some of your options, plus track down intermittent bugs? Very little when using getopt() or getopt_long()!

    Why do you consistently fight the excellent advise you are given by more experienced programmers? Some of us have been there, doen that, made mistakes and learned from those mistakes. Why ask for advice when it will just be ignored when we offer it??? You wonder why readers don't respond to many of your postings!!!

    getopt() may not be part of the C Standard, but is, "POSIX.1-2001, POSIX.1-2008, and POSIX.2"

    Please review the code examples in the man page link above.

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,734
    Quote Originally Posted by rstanley View Post
    So are printf(), scanf() and many other Standard Library functions that you would rather use than rewrite from scratch! Getopt() and getopt_long() are frameworks written, debugged, and proven, that you just use. I don't have to "Hunt down" the actual code, I just use it!

    I don't want to spend vast amounts of time hard coding Command Line Argument options, and other non-option arguments, or end up with 175 lines of complicated code. How much work will it take to Add/Change/Delete some of your options, plus track down intermittent bugs? Very little when using getopt() or getopt_long()!

    Why do you consistently fight the excellent advise you are given by more experienced programmers? Some of us have been there, doen that, made mistakes and learned from those mistakes. Why ask for advice when it will just be ignored when we offer it??? You wonder why readers don't respond to many of your postings!!!

    getopt() may not be part of the C Standard, but is, "POSIX.1-2001, POSIX.1-2008, and POSIX.2"

    Please review the code examples in the man page link above.
    Actually no, I plan to do my own version of sprintfv and map a how bunch to it, I'm tired of PRIdMAX etc when in pedantic mode, only reason I haven't gotten to it already is because dealing with more pressing matters, and there is practically no effort to add new options, just add an if statement to ArgHasIssue(), it's job is to process the option and the values dedicated to it, for example "gcc -o a.out obj1.o obj2.o" would call ArgHasIssue( 1, 3, argv ), the function doesn't give a crap about checking for other options in the values, it just does a more thorough check on argv[1] to identify what it should do with that option and how many values are permitted for the option, ArgHadIssue() takes the same values and chucks out the error returned by ArgHasIssue(), ProcessArgv() is only supposed to detect the presence of any option, it does nothing beyond that, instead fobbing off the task of processing the options to ArgHasIssue() so in reality ProccessArgv() is unlikely to ever change now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading in command line arguments
    By cooper1200 in forum C Programming
    Replies: 1
    Last Post: 05-20-2019, 09:11 AM
  2. Reading arguments from command-line
    By SafetyMark in forum C Programming
    Replies: 2
    Last Post: 10-27-2016, 04:30 PM
  3. Too few arguments issue...
    By pp00 in forum C Programming
    Replies: 3
    Last Post: 11-13-2012, 03:31 PM
  4. Reading terminal arguments
    By DenKain in forum C++ Programming
    Replies: 24
    Last Post: 10-07-2008, 04:37 PM
  5. Problems while reading arguments
    By Lost__Soul in forum C Programming
    Replies: 6
    Last Post: 05-06-2003, 01:02 AM

Tags for this Thread