Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: parameter argc is never used ?

Reply
Thread Tools

Re: parameter argc is never used ?

 
 
Default User
Guest
Posts: n/a
 
      04-01-2004
Old Wolf wrote:
>
> Default User <(E-Mail Removed)> wrote:
> > I meant in this instance. The argc parameter is there for a reason, and
> > should be used any time argv is used. If you are expecting arguments,
> > check to see if any arrived. If not, catch it and report it right in
> > main().

>
> argv is guararanted to be a NULL-terminated list, so it is possible
> to use it without using argc.


Yes, you CAN, but only by iterating over all elements. Why do that when
a simple comparison of an int is available?

This is pretty silly, people coming up with bizarre reasons not to use a
very handy piece of information.




Brian Rodenborn
 
Reply With Quote
 
 
 
 
Julie
Guest
Posts: n/a
 
      04-01-2004
Default User wrote:
>
> Old Wolf wrote:
> >
> > Default User <(E-Mail Removed)> wrote:
> > > I meant in this instance. The argc parameter is there for a reason, and
> > > should be used any time argv is used. If you are expecting arguments,
> > > check to see if any arrived. If not, catch it and report it right in
> > > main().

> >
> > argv is guararanted to be a NULL-terminated list, so it is possible
> > to use it without using argc.

>
> Yes, you CAN, but only by iterating over all elements. Why do that when
> a simple comparison of an int is available?
>
> This is pretty silly, people coming up with bizarre reasons not to use a
> very handy piece of information.
>
> Brian Rodenborn


Default -- nothing against you, but what I find most 'interesting' about this
(and other) threads is the inability of respondents to actually *answer* the
OPs question, but rather why they should be doing it some other way. It makes
it a very daunting effort to post a question to the newsgroup, and I presume
that there are numerous lurkers that refrain from posting for this simple
reason.

Personally, I take the the OPs question *literally* and try to answer what they
are asking. If they want comments on code style, how to do it better, etc.,
let them ask.
 
Reply With Quote
 
 
 
 
Default User
Guest
Posts: n/a
 
      04-01-2004
Julie wrote:

> Default


You can call me Def.

> -- nothing against you, but what I find most 'interesting' about this
> (and other) threads is the inability of respondents to actually *answer* the
> OPs question, but rather why they should be doing it some other way.


There is no answer. The standard does not require a diagnostic, so the
fact that one is issued is an implementation decision.

However, so what? What's wrong with giving a person the real answer,
rather than the one they think they want do to their broken solution to
a problem.

Sometimes, the answer to, "it hurts when I do this" really is, "don't do
that!"

> It makes
> it a very daunting effort to post a question to the newsgroup, and I presume
> that there are numerous lurkers that refrain from posting for this simple
> reason.


Sounds like a load of crap. Nobody was mean to the poster. You have to
be pretty thin-skinned to take advice saying, "rather than try to
suppress the warning, use the parameter and eliminate it" as anything
but constructive advice.

> Personally, I take the the OPs question *literally* and try to answer what they
> are asking. If they want comments on code style, how to do it better, etc.,
> let them ask.


That's foolish. Sorry if that hurts your feelings, but it's true. ANY
person in the position of giving advice who strictly limits themselves
to the actual question does the questioner no service. One should and
really MUST give the person all the information they need to make a
sensible decision.



Brian Rodenborn
 
Reply With Quote
 
Pete Vidler
Guest
Posts: n/a
 
      04-01-2004
Default User wrote:
[snip]
> That's foolish. Sorry if that hurts your feelings, but it's true. ANY
> person in the position of giving advice who strictly limits themselves
> to the actual question does the questioner no service. One should and
> really MUST give the person all the information they need to make a
> sensible decision.

[snip]

In many cases we know so little about the actual problem that it would
be an invalid assumption to think that we know it better than they.
Offering extra advice is often useful, but not at the expense of
answering the /actual/ question (which would be frustrating to the
person doing the asking).

Although in this specific case I think I agree with you.

-- Pete
 
Reply With Quote
 
Julie
Guest
Posts: n/a
 
      04-01-2004
Default User wrote:
> Sounds like a load of crap. Nobody was mean to the poster. You have to
> be pretty thin-skinned to take advice saying, "rather than try to
> suppress the warning, use the parameter and eliminate it" as anything
> but constructive advice.


Yes, no one was mean, but
>
> > Personally, I take the the OPs question *literally* and try to answer what they
> > are asking. If they want comments on code style, how to do it better, etc.,
> > let them ask.

>
> That's foolish. Sorry if that hurts your feelings, but it's true. ANY
> person in the position of giving advice who strictly limits themselves
> to the actual question does the questioner no service. One should and
> really MUST give the person all the information they need to make a
> sensible decision.


Doesn't hurt my feelings at all --

Not foolish, just a fundamental difference -- I prefer to think of the original
poster being capable to ask what they want, and follow-up as necessary, you
don't.
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      04-02-2004
Pete Vidler wrote:
>
> Default User wrote:
> [snip]
> > That's foolish. Sorry if that hurts your feelings, but it's true. ANY
> > person in the position of giving advice who strictly limits themselves
> > to the actual question does the questioner no service. One should and
> > really MUST give the person all the information they need to make a
> > sensible decision.

> [snip]
>
> In many cases we know so little about the actual problem that it would
> be an invalid assumption to think that we know it better than they.
> Offering extra advice is often useful, but not at the expense of
> answering the /actual/ question (which would be frustrating to the
> person doing the asking).


Which is why we ask for complete, minimal programs, so we can give
proper advice.

I knew from looking at this code that the program passed the argv array
to a function without having performed any sanity checks on the number
of input arguments. How much more did I need to know?



Brian Rodenborn
 
Reply With Quote
 
Shea Martin
Guest
Posts: n/a
 
      04-08-2004
Julie wrote:
> Default User wrote:
>
>>Old Wolf wrote:
>>
>>>Default User <(E-Mail Removed)> wrote:
>>>
>>>>I meant in this instance. The argc parameter is there for a reason, and
>>>>should be used any time argv is used. If you are expecting arguments,
>>>>check to see if any arrived. If not, catch it and report it right in
>>>>main().
>>>
>>>argv is guararanted to be a NULL-terminated list, so it is possible
>>>to use it without using argc.

>>
>>Yes, you CAN, but only by iterating over all elements. Why do that when
>>a simple comparison of an int is available?
>>
>>This is pretty silly, people coming up with bizarre reasons not to use a
>>very handy piece of information.
>>
>>Brian Rodenborn

>
>
> Default -- nothing against you, but what I find most 'interesting' about this
> (and other) threads is the inability of respondents to actually *answer* the
> OPs question, but rather why they should be doing it some other way. It makes
> it a very daunting effort to post a question to the newsgroup, and I presume
> that there are numerous lurkers that refrain from posting for this simple
> reason.
>
> Personally, I take the the OPs question *literally* and try to answer what they
> are asking. If they want comments on code style, how to do it better, etc.,
> let them ask.

Amen
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      04-08-2004
Shea Martin <(E-Mail Removed)> spoke thus:

> (snip tons of irrelevant quoted text)


> Amen


That was a lot to "Amen". Please learn to quote judiciously. Thanks.

--
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.
 
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
You've never seen it before and you'll never see it again. Fred A Stover Computer Support 7 12-26-2007 03:33 AM
XML Schema never-never occurence of declared elements / attributes Soren Kuula XML 1 12-01-2005 01:27 PM
To void parameter 'argc' is never used hpy_awad@yahoo.com C Programming 19 05-25-2004 05:46 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
string routines go to never never land on unix Kevin C Programming 4 10-17-2003 06:07 PM



Advertisments