getopt()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • k_over_hbarc@yahoo.com

    #1

    getopt()

    What is the correct format of getopt() and how does it work? I looked
    at the man page; it doesn't really clarify things. What's a program
    that uses it, maybe I could figure it out from that.

    Note: This is on-topic. getopt is part of the standard library.

    Andrew Usher

  • Arthur J. O'Dwyer

    #2
    Re: getopt()


    [fups set to c.p]

    On Sun, 5 Nov 2005 k_over_hbarc@ya hoo.com wrote:[color=blue]
    >
    > What is the correct format of getopt() and how does it work? I looked
    > at the man page; it doesn't really clarify things. What's a program
    > that uses it, maybe I could figure it out from that.[/color]

    man 3 getopt
    (is not the same as)
    man getopt
    [color=blue]
    > Note: This is on-topic. getopt is part of the standard library.[/color]

    Note: getopt is certainly *NOT* part of the standard library; I don't
    know where you got that idea. Questions such as yours which are not
    related to ISO standard C should be directed to a group where they'd be
    on-topic, such as comp.programmin g, one of the gnu. hierarchy, or perhaps
    a Linux programming group.

    -Arthur

    Comment

    • Ben Pfaff

      #3
      Re: getopt()

      k_over_hbarc@ya hoo.com writes:
      [color=blue]
      > getopt is part of the standard library.[/color]

      No it isn't.
      --
      "...deficie nt support can be a virtue.
      It keeps the amateurs off."
      --Bjarne Stroustrup

      Comment

      • k_over_hbarc@yahoo.com

        #4
        Re: getopt()

        Ben Pfaff wrote:[color=blue]
        > k_over_hbarc@ya hoo.com writes:
        >[color=green]
        > > getopt is part of the standard library.[/color]
        >
        > No it isn't.[/color]

        ??? It is in libc. Maybe it's Unix-specific, but C is Unix.

        Andrew Usher

        Comment

        • Keith Thompson

          #5
          Re: getopt()

          k_over_hbarc@ya hoo.com writes:[color=blue]
          > Ben Pfaff wrote:[color=green]
          >> k_over_hbarc@ya hoo.com writes:
          >>[color=darkred]
          >> > getopt is part of the standard library.[/color]
          >>
          >> No it isn't.[/color]
          >
          > ??? It is in libc. Maybe it's Unix-specific, but C is Unix.[/color]

          libc is not the standard C library (i.e., the library defined by the C
          language standard).

          C is a language; Unix is an operating system. C is not Unix; Unix is
          not C.

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
          We must do something. This is something. Therefore, we must do this.

          Comment

          • k_over_hbarc@yahoo.com

            #6
            Re: getopt()

            Keith Thompson wrote:
            [color=blue][color=green]
            > > ??? It is in libc. Maybe it's Unix-specific, but C is Unix.[/color]
            >
            > libc is not the standard C library (i.e., the library defined by the C
            > language standard).[/color]

            That library doesn't exist! The only C is the one people actually use.
            I don't care for bureaucratic s*** here more than anywhere else.
            [color=blue]
            > C is a language; Unix is an operating system. C is not Unix; Unix is
            > not C.[/color]

            I know that, obviously. But C is written for Unix and vice versa.

            Andrew Usher

            P.S. As far as getopt(), I wrote some test programs and I think I have
            figured it out. It doesn't really work well with a ':' other than at
            the end, though. I think anyone who's serious about processing command
            lines would write his own modification.

            Comment

            • Keith Thompson

              #7
              Re: getopt()

              k_over_hbarc@ya hoo.com writes:[color=blue]
              > Keith Thompson wrote:[color=green][color=darkred]
              >> > ??? It is in libc. Maybe it's Unix-specific, but C is Unix.[/color]
              >>
              >> libc is not the standard C library (i.e., the library defined by the C
              >> language standard).[/color]
              >
              > That library doesn't exist! The only C is the one people actually use.
              > I don't care for bureaucratic s*** here more than anywhere else.[/color]

              The topic of this newsgroup is the C language as defined by the
              standard (which doesn't include getopt). If you want to discuss
              something else, there are other newsgroups; in comp.unix.progr ammer,
              for example, they're far more likely to be able to answer your
              questions than we are.

              --
              Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
              San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
              We must do something. This is something. Therefore, we must do this.

              Comment

              • slebetman@gmail.com

                #8
                Re: getopt()

                k_over_hbarc@ya hoo.com wrote:[color=blue]
                > but C is Unix.[/color]

                So what do you call Windows3.1 then? Unix??? It certainly was written
                in C as much as any variant of Unix were.

                I've written on systems where their libc includes support for CANbus
                and ARCnet but I recognise that they were vendor specific additions to
                libc. Just because gcc has its own extended libc doesn't mean that ALL
                C compilers need to emulate it to conform to C standards (ANSI, C99,
                etc).

                Comment

                • pete

                  #9
                  Re: getopt()

                  k_over_hbarc@ya hoo.com wrote:
                  [color=blue]
                  > I don't care for bureaucratic s*** here more than anywhere else.[/color]

                  I think the problem with this newgroup,
                  is that "comp.lang. c" is too easy to spell.

                  http://www.csclub.uwaterloo.ca/u/dj3...lc-welcome.txt

                  news:comp.unix. programmer

                  --
                  pete

                  Comment

                  • Martin Ambuhl

                    #10
                    Re: getopt()

                    k_over_hbarc@ya hoo.com wrote:
                    [color=blue]
                    > Note: This is on-topic. getopt is part of the standard library.[/color]

                    On what do you base this obviously false assertion?

                    Comment

                    • Nick Keighley

                      #11
                      Re: getopt()

                      k_over_hbarc@ya hoo.com wrote:[color=blue]
                      > Keith Thompson wrote:[/color]
                      [color=blue][color=green][color=darkred]
                      > > > ??? It is in libc. Maybe it's Unix-specific, but C is Unix.[/color]
                      > >
                      > > libc is not the standard C library (i.e., the library defined by the C
                      > > language standard).[/color]
                      >
                      > That library doesn't exist! The only C is the one people actually use.
                      > I don't care for bureaucratic s*** here more than anywhere else.[/color]

                      did you notice that you are the only person in this thread that thinks
                      that. Could it
                      perhaps be that you are wrong?

                      <snip>


                      --
                      Nick Keighley

                      The use of COBOL cripples the mind; its teaching should, therefore,
                      be regarded as a criminal offense. -E. W. Dijkstra

                      Comment

                      • Malcolm

                        #12
                        Re: getopt()

                        <k_over_hbarc@y ahoo.com> wrote[color=blue]
                        >
                        > That library doesn't exist! The only C is the one people actually use.
                        > I don't care for bureaucratic s*** here more than anywhere else.
                        >[/color]
                        It is not just bureaucratese.
                        If write a program in ANSI C, then you can guarantee that it will compile
                        and run on any system with a ANSI C compiler. If it doesn't you can complain
                        to the compiler vendor, and he will either have to post a fix or remove the
                        claim to ANSI compatibility.
                        On the other hand if you use a non-standard function like getopt(), you may
                        end up having to implement it youself. There is no getopt() on my Windows C
                        compiler, for instance.[color=blue]
                        >[color=green]
                        >> C is a language; Unix is an operating system. C is not Unix; Unix is
                        >> not C.[/color]
                        >
                        > I know that, obviously. But C is written for Unix and vice versa.
                        >[/color]
                        They grew up together. And C works more nicely on Unix than any other
                        system. However only a minority of my C programs have been for Unix - most
                        are either Windows or games console programs.


                        Comment

                        • Mike Wahler

                          #13
                          Re: getopt()


                          "Keith Thompson" <kst-u@mib.org> wrote in message
                          news:lnirv6b62q .fsf@nuthaus.mi b.org...[color=blue]
                          > k_over_hbarc@ya hoo.com writes:[color=green]
                          >> Ben Pfaff wrote:[color=darkred]
                          >>> k_over_hbarc@ya hoo.com writes:
                          >>>
                          >>> > getopt is part of the standard library.
                          >>>
                          >>> No it isn't.[/color]
                          >>
                          >> ??? It is in libc. Maybe it's Unix-specific, but C is Unix.[/color]
                          >
                          > libc is not the standard C library (i.e., the library defined by the C
                          > language standard).
                          >
                          > C is a language; Unix is an operating system. C is not Unix;[/color]

                          Let's start the CNU movement! :-)

                          -Mike


                          Comment

                          • William Ahern

                            #14
                            Re: getopt()

                            k_over_hbarc@ya hoo.com wrote:[color=blue]
                            > What is the correct format of getopt() and how does it work? I looked
                            > at the man page; it doesn't really clarify things. What's a program
                            > that uses it, maybe I could figure it out from that.[/color]
                            [color=blue]
                            > Note: This is on-topic. getopt is part of the standard library.[/color]

                            getopt is defined in the Standard Unix Specification, not ANSI C.
                            The online SUSv3 description has example usage:



                            And of course, there are about a gazillion Free Software programs out there
                            that use getopt, all with viewable, usable and redistributable source code.

                            Direct any questions to comp.unix.progr ammer.

                            Comment

                            • Mark McIntyre

                              #15
                              Re: getopt()

                              On 5 Nov 2005 22:13:49 -0800, in comp.lang.c , k_over_hbarc@ya hoo.com
                              wrote:
                              [color=blue]
                              >Ben Pfaff wrote:[color=green]
                              >> k_over_hbarc@ya hoo.com writes:
                              >>[color=darkred]
                              >> > getopt is part of the standard library.[/color]
                              >>
                              >> No it isn't.[/color]
                              >
                              >??? It is in libc.[/color]

                              So are lots of things platform-specific.
                              [color=blue]
                              >Maybe it's Unix-specific,[/color]

                              It may be POSIX, but you'd have to ask in a unix group to find out.
                              [color=blue]
                              >but C is Unix.[/color]

                              Not since about 1970. Get with the right millenium
                              --
                              Mark McIntyre
                              CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
                              CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >

                              ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
                              http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
                              ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

                              Comment

                              Working...