473,395 Members | 1,443 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,395 software developers and data experts.

Type of argv parameter of main( )

In the SECOND EDITION of the book "The C Programming Language - ANSI
C" by K & R,
the following is mentioned:

In page 114, in Section 5.10 "Command-line Arguments", it is mentioned
that argv is a pointer to an array of character strings. Again on the
next page 115, it is mentioned that argv is a pointer to an array of
pointers.

However in the example that follows this statement in this book, the
program is given as mentioned below:

#include <stdio.h>

main(int argc, char *argv[ ] )
{
while (--argc 0)
printf("%s%s", *++argv, (argc 1) ? " " : "");

printf("\n");
return 0;
}

MY DOUBT:
-----------------
If argv is a pointer to array of character strings as mentioned in
these pages, should not the parameter type be char * (*argv)[ ] ?

Someone kindly explain.

Feb 15 '07 #1
14 6168
subramanian said:
In the SECOND EDITION of the book "The C Programming Language - ANSI
C" by K & R,
the following is mentioned:

In page 114, in Section 5.10 "Command-line Arguments", it is mentioned
that argv is a pointer to an array of character strings. Again on the
next page 115, it is mentioned that argv is a pointer to an array of
pointers.
Well, close. argv is a pointer to the first element in an array of
pointers.
MY DOUBT:
No, it's not your doubt. It's your question.

If argv is a pointer to array of character strings as mentioned in
these pages, should not the parameter type be char * (*argv)[ ] ?
Yes, if argv were a pointer to an array, the type would indeed be
different. K&R are using terminology very loosely here. In my opinion,
that's a mistake on their part.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 15 '07 #2
On Feb 14, 9:58 pm, "subramanian" <subramanian10...@yahoo.comwrote:
In page 114, in Section 5.10 "Command-line Arguments", it is mentioned
that argv is a pointer to an array of character strings. Again on the
next page 115, it is mentioned that argv is a pointer to an array of
pointers.
I think they're speaking in the sense that if you have int x[10], x
points to the first element of the array. They could have definitely
been more clear.

It's not correct to say that argv is _of_type_ "pointer to array of
pointers to chars", even though it's true in code that argv points to
the array of pointers to chars.

argv is officially char *argv[] (type array of char*), or char **argv
(type pointer to char*), or the equivalent.

-Beej

Feb 15 '07 #3
Beej said:

<snip>
>
argv is officially char *argv[] (type array of char*),
No, char *argv[], in a formal parameter context, means "argv is a
pointer to pointer to char", not an array of anything. See pp99-100 of
K&R2 for informal verification of this.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 15 '07 #4
On Feb 14, 11:27 pm, Richard Heathfield <r...@see.sig.invalidwrote:
No, char *argv[], in a formal parameter context, means "argv is a
pointer to pointer to char", not an array of anything. See pp99-100 of
K&R2 for informal verification of this.
I stand corrected.

-Beej

Feb 15 '07 #5
On 15 Feb, 06:38, Richard Heathfield <r...@see.sig.invalidwrote:
subramanian said:
MY DOUBT:

No, it's not your doubt. It's your question.
I thought we'd already had this discussion. The use of "doubt" to mean
question or perhaps better "uncertainty" is a common usage in "Indian"
English. If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.

Feb 15 '07 #6
In article <11**********************@v33g2000cwv.googlegroups .com>,
<ma**********@pobox.comwrote:
>On 15 Feb, 06:38, Richard Heathfield <r...@see.sig.invalidwrote:
>subramanian said:
MY DOUBT:

No, it's not your doubt. It's your question.

I thought we'd already had this discussion. The use of "doubt" to mean
question or perhaps better "uncertainty" is a common usage in "Indian"
English. If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.
It is just a pretty good indicator of where you are on the
jag-o-meter. Clearly, and this has been shown many times, RH is further
down the road than is KT. They're both pretty high scorers (on the
jag-o-meter), of course, but RH is further gone.

Or, to put it another way, RH exists to make KT seem at least somewhat
reasonable.

Feb 15 '07 #7
ma**********@pobox.com said:
On 15 Feb, 06:38, Richard Heathfield <r...@see.sig.invalidwrote:
>subramanian said:
MY DOUBT:

No, it's not your doubt. It's your question.

I thought we'd already had this discussion.
Mark, we've already had *every* discussion. :-)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 15 '07 #8
ma**********@pobox.com wrote:
On 15 Feb, 06:38, Richard Heathfield <r...@see.sig.invalidwrote:
>subramanian said:
>>MY DOUBT:

No, it's not your doubt. It's your question.

I thought we'd already had this discussion. The use of "doubt" to
mean question or perhaps better "uncertainty" is a common usage
in "Indian" English. If, as someone (I think it was Keith T)
recently pointed out, this is an international newsgroup, a
little tolerance of variant English is probably appropriate.
There is a difference between the laziness of "text speak"
(u no wht I mn) and someone expressing themselves in their own
idiomatic variant of English.
In fact, I suspect the majority of the worlds English speakers are
Indian today. If USAnians can use Amerenglish, why can't Indians
use Indenglish? At any rate the only pure English is found in
Canada, eh. :-) The real point is that we all have a reasonable
expectation of understanding one another.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Feb 16 '07 #9
ma**********@pobox.com wrote:
On 15 Feb, 06:38, Richard Heathfield <r...@see.sig.invalidwrote:
subramanian said:
MY DOUBT:
No, it's not your doubt. It's your question.

I thought we'd already had this discussion. The use of "doubt" to mean
question or perhaps better "uncertainty" is a common usage in "Indian"
English.
And the use of "loose" to mean "lose" is a common usage in "Internet"
English, but it's equally wrong.
If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.
The problem is that "doubt" already means something, and what it does
mean is not "question".

Really. It's just a doubt of educating these people who murder the
English language. (See how stupid that sounds?)

Richard
Feb 16 '07 #10
On 16 Feb, 10:39, r...@hoekstra-uitgeverij.nl (Richard Bos) wrote:
mark_blue...@pobox.com wrote:
On 15 Feb, 06:38, Richard Heathfield <r...@see.sig.invalidwrote:
subramanian said:
MY DOUBT:
No, it's not your doubt. It's your question.
I thought we'd already had this discussion. The use of "doubt" to mean
question or perhaps better "uncertainty" is a common usage in "Indian"
English.

And the use of "loose" to mean "lose" is a common usage in "Internet"
English, but it's equally wrong.
If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.

The problem is that "doubt" already means something, and what it does
mean is not "question".
But it can mean "uncertainty" and I think that, rather than
"question", is what Indian English often means by it.
Really. It's just a doubt of educating these people who murder the
English language. (See how stupid that sounds?)
On the other hand I have a doubt whether or not you were joking in
that sentence.

By the way - what English language do you mean?

Feb 16 '07 #11
Richard Bos wrote:
ma**********@pobox.com wrote:
.... snip ...
>
And the use of "loose" to mean "lose" is a common usage in
"Internet" English, but it's equally wrong.
That is simply a matter of sloppy spelling, assisted by
prononciation variants.
>
>If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.

The problem is that "doubt" already means something, and what it
does mean is not "question".

Really. It's just a doubt of educating these people who murder the
English language. (See how stupid that sounds?)
The usage of doubt is perfectly understandable to all. "I have a
doubt" implies the writers uncertainty of his own understanding of
something. Many moons ago I had an English girlfriend who
requested that I "knock me up in the morning". I was willing, but
had second thoughts about the language usage involved.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Feb 16 '07 #12
In article <45***************@yahoo.com>,
CBFalconer <cb********@maineline.netwrote:
>Richard Bos wrote:
>ma**********@pobox.com wrote:
... snip ...
>>
And the use of "loose" to mean "lose" is a common usage in
"Internet" English, but it's equally wrong.

That is simply a matter of sloppy spelling, assisted by
prononciation variants.
>>
>>If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.

The problem is that "doubt" already means something, and what it
does mean is not "question".

Really. It's just a doubt of educating these people who murder the
English language. (See how stupid that sounds?)

The usage of doubt is perfectly understandable to all. "I have a
doubt" implies the writers uncertainty of his own understanding of
something.
Really, it is just like everything else in this newsgroup.
Pointing out that this usage of "doubt" is wrong (and that it *sounds*
wrong - which is really the point) is entirely correct, but like
pointing out that something isn't in the C standard, ultimately
irrelevant.

Feb 16 '07 #13
Kenny McCormack wrote:
Richard Bos wrote:
ma**********@pobox.com wrote:
<snip>
>If, as someone (I think it was Keith T) recently pointed out,
this is an international newsgroup, a little tolerance of variant
English is probably appropriate. There is a difference between the
laziness of "text speak" (u no wht I mn) and someone expressing
themselves in their own idiomatic variant of English.

The problem is that "doubt" already means something, and what it
does mean is not "question".

Really. It's just a doubt of educating these people who murder the
English language. (See how stupid that sounds?)
<snip>
Really, it is just like everything else in this newsgroup.
Pointing out that this usage of "doubt" is wrong (and that it *sounds*
wrong - which is really the point) is entirely correct, but like
pointing out that something isn't in the C standard, ultimately
irrelevant.
It unlikely that the OP, after having taken the trouble of posting,
would not bother to read the replies, thus missing the chance to get a
"western" perspective on his English. I've observed here instances,
admittedly rare, of posters who've taken note of these types of non-
topical advices.

Feb 16 '07 #14
CBFalconer <cb********@yahoo.comwrote:
Richard Bos wrote:
Really. It's just a doubt of educating these people who murder the
English language. (See how stupid that sounds?)

The usage of doubt is perfectly understandable to all. "I have a
doubt" implies the writers uncertainty of his own understanding of
something.
Yah. Of the Queen's English :-P

Richard
Feb 19 '07 #15

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

Similar topics

8
by: CAFxX | last post by:
i'm writing a program that executes some calculations on a bitmap loaded in memory. these calculation ends up with pixel wth values far over 255, but i need them to be between 0 and 255 since i...
21
by: Bret | last post by:
I'm curious why char** argv is acceptable in the main() declaration. In the comp.lang.c FAQ (question 6.18) it says that pointers to pointers and pointers to an array are not interchangable. ...
14
by: Hal Styli | last post by:
Is this a style thing? int main(int argc, char *argv ) or int main(int argc, char **argv ) i.e. *argv or **argv Why choose the latter?
2
by: leo2100 | last post by:
Hi, I need help with this program. The program is supposed to take a text file and identify the words in it, then it should print them and count how many times a word is repeated. At first main...
22
by: Joe Smith | last post by:
It is nothing short of embarrassing to feel the need to ask for help on this. I can't see how I would make the main control for this. What I want is a for loop and a test condition. And while I...
7
by: =?Utf-8?B?Vmlu?= | last post by:
Hi, I have a question. I created a simple executable program using Visual C++ from Visual Studio 6.0 This program is called from a script that passes in one argument. Now, my question is: ...
9
by: weirdwoolly | last post by:
Hopefully someone will be able to help. I have written a stored procedure in C++ called from a Java test harness to validate the graphic data types in C++ and their use. I have declared the...
3
by: Martin T. | last post by:
Hello. I tried to overload the operator<< for implicit printing of wchar_t string on a char stream. Normally using it on a ostream will succeed as std::operator<<<std::char_traits<char> will...
2
by: Ben Bacarisse | last post by:
candide <candide@free.invalidwrites: argv can't be an array. It is a function parameter and arrays can't be passed to functions in C. There is indeed an array "out there" but all main can...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.