By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,942 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a

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

P: n/a
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>

lovecreatesbeauty

Jun 21 '06 #4

P: n/a
lovecreatesbeauty 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

P: n/a

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
$

lovecreatesbeauty

Jun 21 '06 #6

P: n/a
In article <11**********************@y41g2000cwy.googlegroups .com> "lovecreatesbeauty" <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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.