473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

which is const in "char *const argv[]"

Hi
For this code,
int getopt (int argc, char *const argv[], const char *opts)
what does the "char *const argv[]" mean? Does it equal to "char **const
argv"?
Or "char *const *argv"? Which is the const?

Thanks

Jun 20 '06 #1
7 8525
Eric schrieb:
For this code,
int getopt (int argc, char *const argv[], const char *opts)
what does the "char *const argv[]" mean? Does it equal to "char **const
argv"?
Or "char *const *argv"? Which is the const?


char * const * argv.
I suggest that you get yourself a little programme called cdecl:
,---
$ cdecl
Type `help' or `?' for help
cdecl> explain char *const argv[]
declare argv as array of const pointer to char
cdecl> explain char *const *argv
declare argv as pointer to const pointer to char
`---
which of course is equivalent for function parameters

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jun 20 '06 #2

Eric wrote:
Hi
For this code,
int getopt (int argc, char *const argv[], const char *opts)
what does the "char *const argv[]" mean? Does it equal to "char **const
argv"?
Or "char *const *argv"? Which is the const?

Thanks


char * const * argv -- argv is a pointer to a const pointer to char;
essentially, argv is an array of const pointers.

Jun 20 '06 #3
Michael Mair wrote:
I suggest that you get yourself a little programme called cdecl:


cdecl seems no much help, e.g.:

cdecl> explain void (*signal(int sig, void (*func)(int)))( int);
parse error
cdecl> explain int main(int argc, char *argv[]);
parse error
cdecl> explain int main(void);
declare main as function (void) returning int
cdecl>

lovecreatesbeau ty

Jun 21 '06 #4
lovecreatesbeau ty wrote:
Michael Mair wrote:
I suggest that you get yourself a little programme called cdecl:


cdecl seems no much help, e.g.:

cdecl> explain void (*signal(int sig, void (*func)(int)))( int);
parse error
cdecl> explain int main(int argc, char *argv[]);
parse error
cdecl> explain int main(void);
declare main as function (void) returning int
cdecl>


cdecl doesn't properly support function prototypes. Its manpage tells
me that's because it was written before C89 was completed. Try it
without the parameter names:

cdecl> explain void (*signal(int, void (*)(int)))(int)
declare signal as function (int, pointer to function (int) returning
void) returning pointer to function (int) returning void

Jun 21 '06 #5

Harald van Dijk wrote:
cdecl doesn't properly support function prototypes. Its man page tells
me that's because it was written before C89 was completed. Try it
without the parameter names:


Ok, following is the version information about cdecl on my Debian
Linux. Perhaps the year C89 was released is earlier than the year when
cdecl at 2.5 1/15/96. :)

$ pwd
/home/jhl/cdecl_2.5-6_i386
$ cdecl -V
Version:
@(#)cdecl.c 2.5 1/15/96
@(#)cdgram.y 2.2 3/30/88
@(#)cdlex.l 2.2 3/30/88
$

lovecreatesbeau ty

Jun 21 '06 #6
In article <11************ **********@y41g 2000cwy.googleg roups.com> "lovecreatesbea uty" <lo************ ***@gmail.com> writes:
Harald van D=C4=B3k wrote:
cdecl doesn't properly support function prototypes. Its man page tells
me that's because it was written before C89 was completed. Try it
without the parameter names:
.... Ok, following is the version information about cdecl on my Debian
Linux. Perhaps the year C89 was released is earlier than the year when
cdecl at 2.5 1/15/96. :)

$ pwd
/home/jhl/cdecl_2.5-6_i386
$ cdecl -V
Version:
@(#)cdecl.c 2.5 1/15/96
@(#)cdgram.y 2.2 3/30/88
@(#)cdlex.l 2.2 3/30/88
$


Probably a minor bugfix compared to:
@(#)cdecl.c 2.4 3/31/88
But note the date of cdlex (which does the parsing).

--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Jun 21 '06 #7
Uh ah, cdecl is really an interesting programme! Thanks.

Michael Mair wrote:
Eric schrieb:
For this code,
int getopt (int argc, char *const argv[], const char *opts)
what does the "char *const argv[]" mean? Does it equal to "char **const
argv"?
Or "char *const *argv"? Which is the const?


char * const * argv.
I suggest that you get yourself a little programme called cdecl:
,---
$ cdecl
Type `help' or `?' for help
cdecl> explain char *const argv[]
declare argv as array of const pointer to char
cdecl> explain char *const *argv
declare argv as pointer to const pointer to char
`---
which of course is equivalent for function parameters

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.


Jun 22 '06 #8

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

Similar topics

2
2570
by: srktnc | last post by:
When I run the program, I get a Debug Error saying "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." I put a cout statement (//cout << "len of cPtr: " << _len << endl; ) in my constructor and see that _len is 3435973837 though my character pointer has only a few characters. Then I get the usual message as state above.
4
6073
by: C. J. Clegg | last post by:
A month or so ago I read a discussion about putting const ints in header files, and how one shouldn't put things in header files that allocate memory, etc. because they will generate multiple definition errors if the header file is #include'd in more than one code file. The answer was that constants have internal linkage unless declared extern, so it's OK. So, you can put something like...
26
11696
by: =?gb2312?B?wNbA1rTzzOzKpg==?= | last post by:
i wrote: ----------------------------------------------------------------------- ---------------------------------------- unsigned char * p = reinterpret_cast<unsigned char *>("abcdg"); sizeof(reinterpret_cast<const char *>(p)); ----------------------------------------------------------------------- ---------------------------------------- the compiler tells me that "reinterpret_cast from type "const char * " to type "unsigned char *"...
20
3538
by: liujiaping | last post by:
I'm confused about the program below: int main(int argc, char* argv) { char str1 = "abc"; char str2 = "abc"; const char str3 = "abc"; const char str4 = "abc"; const char* str5 = "abc";
4
8387
by: Virtual_X | last post by:
some function make the data type of it's parameters as "const char*" why not use char or char* instead what would be different
7
3038
by: Bill Davy | last post by:
I want to be able to write (const char*)v where v is an item of type Class::ToolTypeT where ToolTypeT is an enumeration and I've tried everything that looks sensible. There's an ugly solution, but surely this is possible? I could define an operator<< but for various reasons, I really want to convert to a 'const char*' (to embed into a string which becomes part of a window's caption, etc).
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.