Re: How to increment array of pointers to strings

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 *).

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.

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.
Morris Keesan -- mkeesan@xxxxxxxxxxxxxxxx

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 ...
  • 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 ...
  • 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. ...
  • 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 ...
  • Re: kandr2 question
    ... int getline (char s, int lim) ... I dislike using array notation for pointer parameters; ... first element of an array. ...