Re: How to increment array of pointers to strings



"Morris Keesan" <mkeesan@xxxxxxxxxxxxxxxx> writes:
On Wed, 04 Aug 2010 18:50:50 -0400, Keith Thompson <kst-u@xxxxxxx> wrote:
barncat <thebarncat@xxxxxxxxx> writes:
[...]
Thanks. The array is actually a ptr to an array of strings, like:
char *name[] = { "one","two","three" };
which yes, i guess is different than **argv.
sorry, i am just confused trying to learn. I guess i could make it an
** object like argv and work with it that way.

Given the above declaration, name is a pointer to the first element
of an array of char*, where each char* happens to point to (the
first character of) a string. (A pointer to an array is not the same
as a pointer to the array's first element.)

Um, ... no. Given the above declaration, name is not any kind of pointer.
It's an array of (char *).

D'oh! You're right, of course. Dumb mistake on my part.

In most cases, when name appears in an expression it will be *converted*
to a pointer to the first element of the array, but name is most definitely
an array, and not a pointer.

Yup.

Remember: in spite of several features of C that seem to conspire
to make you think otherwise, arrays are not pointers, and pointers are
not arrays.

Remember: even though in usage they usually get converted to pointers,
arrays are not pointers.

Right.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: Problem with va_ macros and arrays of arrays
    ... > the arrays passed to a ... > specific char, somewhat similar to what the standard function ... that with an array of struct, or possibly a pointer to a dynamic array ... > As I'm still a beginner in C without a copy of the standard I ...
    (comp.lang.c)
  • Re: Difference between Char* ptr and char arrCh []
    ... I have a few queries regarding array of characters using array ... notation and pointer notation. ... Is there a difference in storage of global char* and char* inside ...
    (comp.lang.c)
  • Re: Returning pointer to array problem II
    ... Iam trying to make program were I enter string and serach char. ... and funktion prints out witch position char is found this is done if funktion serach_char. ... so far all good what I want do next is: return, from funktion, pointer value to array were positions is stored. ...
    (comp.lang.c)
  • Re: C needs to grow up a little, move with the times, expand its horizons
    ... So "char *p" can be either a pointer to char or a pointer to an array of ... pointer to the first element of the array). ...
    (comp.lang.c)
  • Re: Simple question on Pointers
    ... int main ... It stores 12 char and only 12 ... pointer to the first element of the array with type pointer to element ...
    (microsoft.public.vc.language)