Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: const char * const *argv ?? (http://www.velocityreviews.com/forums/t277227-re-const-char-const-argv.html)

Victor Bazarov 08-30-2003 08:43 PM

Re: const char * const *argv ??
 
"Gizmo" <scottamillard@hotmail.com> 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.

Victor




All times are GMT. The time now is 04:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.