Re: const char * const *argv ??

Discussion in 'C++' started by Victor Bazarov, Aug 30, 2003.

  1. "Gizmo" <> 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 == 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
    Victor Bazarov, Aug 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bret

    char **argv vs. char* argv[]

    Bret, Aug 31, 2003, in forum: C Programming
    Replies:
    21
    Views:
    4,548
    Richard Heathfield
    Sep 3, 2003
  2. David
    Replies:
    10
    Views:
    5,911
    Richard Heathfield
    Sep 15, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,608
    Old Wolf
    Jan 20, 2004
  4. jab3

    char **argv & char *argv[]

    jab3, Dec 4, 2004, in forum: C Programming
    Replies:
    5
    Views:
    646
    Chris Torek
    Dec 8, 2004
  5. oogie
    Replies:
    9
    Views:
    643
    Default User
    Nov 18, 2007
Loading...

Share This Page