Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > using getopt() more than once

Reply
Thread Tools

using getopt() more than once

 
 
Praveen
Guest
Posts: n/a
 
      12-19-2004
Hi,

Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"

First I have to check for -c option and use the value of this -x
argument for next get opt.

Any one has an experience in the same. The reply will be highly
appreciated.

Regards
Praveen Kumar M

 
Reply With Quote
 
 
 
 
Malcolm
Guest
Posts: n/a
 
      12-19-2004

"Praveen" <> wrote
> Any one ever used getopt function more than once. Here is my example.
> I have to run a process as
>
> myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"
>

The thing to do in these situations is first, read the documentation for the
function, and second do a bit of exploratory programming. Just get the
options and echo them to stdout.
getopt() is not an ANSI function and it is years since I last used it, so I
couldn't tell you exactly how it works.


 
Reply With Quote
 
 
 
 
Giovanni
Guest
Posts: n/a
 
      12-19-2004
Praveen wrote:
> Hi,
>
> Any one ever used getopt function more than once. Here is my example.
> I have to run a process as
>
> myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"
>
> First I have to check for -c option and use the value of this -x
> argument for next get opt.
>
> Any one has an experience in the same. The reply will be highly
> appreciated.
>
> Regards
> Praveen Kumar M
>


I don't really understand what you mean. But in the manner you wrote it
and assuming that -c is specified with an argument ("c:" in the option
string) the string "-a -f myFile -o myOutput -d debugFile" is parsed as
a single argument to -c. Otherwise will be parsed as a positional argument.

I don't think you can parse it using getopt() since it is a single
string not an array of pointers to the single word.

Ciao
Giovanni
--
A computer is like an air conditioner,
it stops working when you open Windows.
Registered Linux user #337974 <http://counter.li.org/>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com Java 0 03-06-2008 08:11 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
Why Does Page.IsPostBack Fire More Than Once When Using Firefox? Joey ASP .Net 2 08-06-2007 01:23 PM
Regex to match say char 't' exactly once in a string and no more than once Gancy Perl Misc 4 02-03-2005 02:05 PM



Advertisments