Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: const char * const *argv ??

Thread Tools

Re: const char * const *argv ??

Victor Bazarov
Posts: n/a
"Gizmo" <(E-Mail Removed)> wrote...
> [...]
> const char * const *argv
> iv never seen somthing decleared like this before and wonder if some one
> could explain it to me plz ?? [...]

'argv' is a pointer to a const pointer to a const char.

Since it's a pointer, even if it points to an array of
those pointers, you cannot find out its size unless there
is a particular something that indicates the end of the
array (like a null pointer, for example). The same goes
for pointers to char. An array of char can only be called
"a string" if there is a null character at the end of it.

When 'main' is declared as

int main(int argc, char *argv[])

, argv points to the first pointer in an array. And we
can tell how many elements there is in that array by (a)
looking at 'argc' because that's the role of 'argc' and
by (b) counting until we see argv[i] == 0. It is required
by the Standard that 'argv' contains 'argc+1' elements and
the last element is a null pointer. So, with your function
it is possible that 'argc' also indicates how many pointers
in 'argv' there are.


Reply With Quote

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
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
Is char** (or char*[]) implicitly convertible to 'const char * const *'? C Programming 24 10-30-2005 08:07 AM
extern const char * vs. extern const char [] Thomas Matthews C++ 5 08-02-2004 10:36 AM
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static' Santa C Programming 1 07-17-2003 02:10 PM