getopt

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ramiro Rodriguez

    getopt

    In C there is a function to easily parse command line arguments called
    getopt. Is there such a function in c++

    RR
  • Mike Wahler

    #2
    Re: getopt

    "Ramiro Rodriguez" <ergodicsum@yah oo.com> wrote in message
    news:pan.2003.1 0.14.12.14.17.8 65085@yahoo.com ...[color=blue]
    > In C there is a function to easily parse command line arguments called
    > getopt.[/color]

    No there is not. Your implementation might
    provide one as an extension, but it's not
    part of standard C.
    [color=blue]
    >Is there such a function in c++[/color]

    No. If you decide to try to write one, we
    can help.

    -Mike



    Comment

    • Stewart Gordon

      #3
      Re: getopt

      While it was 14/10/03 1:14 pm throughout the UK, Ramiro Rodriguez
      sprinkled little black dots on a white screen, and they fell thus:
      [color=blue]
      > In C there is a function to easily parse command line arguments called
      > getopt. Is there such a function in c++[/color]

      IINM, C++ can call any C function.

      But I'm not sure that getopt is part of standard C or C++.

      But quite recently I wrote a command line reader class that might be to
      your needs (depending on what your needs are). I'll try and get it put
      up somewhere soon.

      Stewart.

      --
      My e-mail is valid but not my primary mailbox. Please keep replies on
      on the 'group where everyone may benefit.

      Comment

      • Sean Fraley

        #4
        Re: getopt

        Ramiro Rodriguez wrote:
        [color=blue]
        > In C there is a function to easily parse command line arguments called
        > getopt. Is there such a function in c++
        >
        > RR[/color]

        1) getopt is part of the POSIX standard, not the ANSI C OR C++ standards.

        2) You should be able to call it from a C++ program with no problems.

        Sean

        Comment

        • Stewart Gordon

          #5
          Re: getopt

          While it was 14/10/03 3:23 pm throughout the UK, Stewart Gordon
          sprinkled little black dots on a white screen, and they fell thus:

          <snip>[color=blue]
          > But quite recently I wrote a command line reader class that might be to
          > your needs (depending on what your needs are). I'll try and get it put
          > up somewhere soon.[/color]

          It's now up, complete with a bit of documentation (just under 8K in total):



          Stewart.

          --
          My e-mail is valid but not my primary mailbox. Please keep replies on
          on the 'group where everyone may benefit.

          Comment

          • E. Robert Tisdale

            #6
            Re: getopt

            Ramiro Rodriguez wrote:
            [color=blue]
            > In C, there is a function to easily parse command line arguments
            > called getopt.[/color]

            I don't think so.
            [color=blue]
            > Is there such a function in C++[/color]

            I used Google



            to search for

            +"C++" +"class GetOpt"

            and found lots of stuff including
            C++ version of the GNU getopt function


            Hope this helps.

            Comment

            • Lorenzo Bettini

              #7
              Re: getopt

              Ramiro Rodriguez wrote:[color=blue]
              > In C there is a function to easily parse command line arguments called
              > getopt. Is there such a function in c++[/color]

              you may want to try GNU Gengetopt that I personally maintain:



              This program generates a C function that uses getopt_long function to
              parse the command line options, to validate them and fills a struct

              I use it also inside C++ programs :-)

              hope this helps
              Lorenzo

              --
              +-----------------------------------------------------+
              | Lorenzo Bettini ICQ# lbetto, 16080134 |
              | PhD in Computer Science |
              | Dip. Sistemi e Informatica, Univ. di Firenze |
              | Tel +39 055 4796741, Fax +39 055 4796730 |
              | Florence - Italy (GNU/Linux User # 158233) |
              | Home Page : http://www.lorenzobettini.it |
              | http://music.dsi.unifi.it XKlaim language |
              | http://www.lorenzobettini.it/purple Cover Band |
              | http://www.gnu.org/software/src-highlite |
              | http://www.gnu.org/software/gengetopt |
              | http://www.lorenzobettini.it/software/gengen |
              +-----------------------------------------------------+

              Comment

              Working...