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

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 8474
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>

lovecreatesbeauty

Jun 21 '06 #4
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

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
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
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
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...
4
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...
26
by: =?gb2312?B?wNbA1rTzzOzKpg==?= | last post by:
i wrote: ----------------------------------------------------------------------- ---------------------------------------- unsigned char * p = reinterpret_cast<unsigned char *>("abcdg");...
20
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
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
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.