473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

Nov 15 '05 #1
18 3214

[fups set to c.p]

On Sun, 5 Nov 2005 k_**********@yahoo.com wrote:

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.
man 3 getopt
(is not the same as)
man getopt
Note: This is on-topic. getopt is part of the standard library.


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.programming, one of the gnu. hierarchy, or perhaps
a Linux programming group.

-Arthur
Nov 15 '05 #2
k_**********@yahoo.com writes:
getopt is part of the standard library.


No it isn't.
--
"...deficient support can be a virtue.
It keeps the amateurs off."
--Bjarne Stroustrup
Nov 15 '05 #3
Ben Pfaff wrote:
k_**********@yahoo.com writes:
getopt is part of the standard library.


No it isn't.


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

Andrew Usher

Nov 15 '05 #4
k_**********@yahoo.com writes:
Ben Pfaff wrote:
k_**********@yahoo.com writes:
> getopt is part of the standard library.


No it isn't.


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


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_Keith) ks***@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.
Nov 15 '05 #5
Keith Thompson wrote:
??? It is in libc. Maybe it's Unix-specific, but C is Unix.
libc is not the standard C library (i.e., the library defined by the C
language standard).


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.
C is a language; Unix is an operating system. C is not Unix; Unix is
not C.


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.

Nov 15 '05 #6
k_**********@yahoo.com writes:
Keith Thompson wrote:
> ??? It is in libc. Maybe it's Unix-specific, but C is Unix.


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


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.


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.programmer,
for example, they're far more likely to be able to answer your
questions than we are.

--
Keith Thompson (The_Other_Keith) ks***@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.
Nov 15 '05 #7
k_**********@yahoo.com wrote:
but C is Unix.


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).

Nov 15 '05 #8
k_**********@yahoo.com wrote:
I don't care for bureaucratic s*** here more than anywhere else.


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
Nov 15 '05 #9
k_**********@yahoo.com wrote:
Note: This is on-topic. getopt is part of the standard library.


On what do you base this obviously false assertion?
Nov 15 '05 #10
k_**********@yahoo.com wrote:
Keith Thompson wrote:

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


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


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.


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

Nov 15 '05 #11
<k_**********@yahoo.com> wrote

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.
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.
C is a language; Unix is an operating system. C is not Unix; Unix is
not C.


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

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.
Nov 15 '05 #12

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
k_**********@yahoo.com writes:
Ben Pfaff wrote:
k_**********@yahoo.com writes:

> getopt is part of the standard library.

No it isn't.


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


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;


Let's start the CNU movement! :-)

-Mike
Nov 15 '05 #13
k_**********@yahoo.com wrote:
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.


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

http://www.opengroup.org/onlinepubs/...ns/getopt.html

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.programmer.
Nov 15 '05 #14
On 5 Nov 2005 22:13:49 -0800, in comp.lang.c , k_**********@yahoo.com
wrote:
Ben Pfaff wrote:
k_**********@yahoo.com writes:
> getopt is part of the standard library.
No it isn't.


??? It is in libc.


So are lots of things platform-specific.
Maybe it's Unix-specific,
It may be POSIX, but you'd have to ask in a unix group to find out.
but C is Unix.


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 =----
Nov 15 '05 #15
On 5 Nov 2005 23:24:25 -0800, in comp.lang.c , k_**********@yahoo.com
wrote:
Keith Thompson wrote:
C is a language; Unix is an operating system. C is not Unix; Unix is
not C.


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


Maybe once upon a time, C was targettted at an early version of unix ,
but that was 30-odd years ago. Unix certainly was never written for
C.
The first proper rockets were targetted at london, does that make the
shuttle 'for' london, and vice-versa?

--
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 =----
Nov 15 '05 #16
k_**********@yahoo.com wrote:

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.

Annnnnnd *plonk*.

Brian
Nov 15 '05 #17
k_**********@yahoo.com wrote:

Keith Thompson wrote:
??? It is in libc. Maybe it's Unix-specific, but C is Unix.
libc is not the standard C library (i.e., the library defined by the C
language standard).


That library doesn't exist! The only C is the one people actually use.


Well, there's no such thing as "the one people actually use", because
there is no "the" C compiler. There are many C compilers available, and
most (if not all) include extensions to the standard. Those extensions
(of which getopt is one) are off-topic here.

There is, however, something called "the" C language, and that is what
is discussed here. (Well, there have been several revisions to "the"
language.)

And, one of the C compilers that I actually use shows:

==========
C:\temp>cl foo.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

foo.c
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:foo.exe
foo.obj
foo.obj : error LNK2001: unresolved external symbol _getopt
foo.exe : fatal error LNK1120: 1 unresolved externals
==========
I don't care for bureaucratic s*** here more than anywhere else.
And off-topic posts aren't welcome here more than anywhere else.

I can hear a lot of plonking going on over that sentence.
C is a language; Unix is an operating system. C is not Unix; Unix is
not C.


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


Since when? C, as defined in the standard and discussed in this group,
doesn't even require an O/S. (It doesn't even require a keyboard and
display.)
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.


Or ask for help in a group where this discussion is not off-topic.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 15 '05 #18
Mike Wahler <mk******@mkwahler.net> wrote:
Let's start the CNU movement! :-)


Or, perhaps the analagous UNC movement, but that would not be popular
with Duke fans, I'm afraid... :-)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Bear | last post by:
I'm stumped. Trying to follow the docs and .. failure. here's the args >>> args '-Middwb@mainex1.asu.edu -AKHAAM@prlinux+898 -CA --D2003-08-20-09:28:13.417 -Ff -Hprlinux...
4
by: Dan Rawson | last post by:
Is there any way to force getopt to process one option first?? I'd like to be able to pass in the name of a configuration file for my application, then have the remaining command-line parameters...
3
by: Dominik Kaspar | last post by:
I tried to use getopt and copied the example from: http://www.python.org/doc/current/lib/module-getopt.html but nothing is working... getopt.GetoptError doesn't seem to exist and when i run the...
3
by: Don Low | last post by:
Hi, I'm going over a script that demonstrates the getopt function. I include the script here: #! /usr/bin/python import sys, getopt, string
6
by: Frans Englich | last post by:
Hello, In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make...
1
by: Andrew | last post by:
Dear Experts, I have a perl program that using Getopt:Std module, when I try to run the GetOpt program, the following error returned: Can’t locate Getopt.pm in @INC (@INC contains:...
14
by: José de Paula | last post by:
Is getopt() and its companions, commonly found in GNU libc and other Unices libc, part of the C standard? Another doubt: I have a switch inside a while loop; is there a way to break out of the...
4
by: pinkfloydhomer | last post by:
I want to be able to do something like: myscript.py * -o outputfile and then have the shell expand the * as usual, perhaps to hundreds of filenames. But as far as I can see, getopt can only...
1
by: Daniel Mark | last post by:
Hello all: I am using getopt package in Python and found a problem that I can not figure out an easy to do . // Correct input D:\>python AddArrowOnImage.py --imageDir=c:/ // Incorrect...
2
by: auditory | last post by:
I have sources written on linux quite long ago. They are compiled good on current linux machine. but not in VS2005. The cause of problem is #include<getopt.h>. Is there any correspoinding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.