How to increment array of pointers to strings



I am trying to increment the pointer of this array, similar to
incrementing *argv[]:
*++argv
printf("%s\n", *argv); /* now prints the arg at argv[1]; */
--
code:
char *args[8];
args[0] = "x";
args[1] = "y";
args[2] = "z";

/* if i use:
args++; or
*args++;
i get error:
xxx.c:18: error: wrong type argument to increment
*/
--
how can i increment the pointer and print the contents of the current
location of it?

Thanks

.



Relevant Pages

  • Re: pointer and 2d array
    ... elements have the same type as pointed at by the pointer. ... Since the array ahas only 3 elements, you can only increment p ... the element type of 'a' is int[3], not int, so it doesn't qualify. ...
    (comp.lang.c)
  • Re: decrement past beginning is valid?
    ... >> I know that incrementing a pointer one past the end of the array is ... It's just a pointer and you can pretty much increment and decrement ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [C]Understanding arrays/pointers
    ... > Why can't I increment the value of array if it is a pointer? ... If the array is on the heap then yes it is a pointer. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: How to increment array of pointers to strings
    ... barncat writes: ... how can i increment the pointer and print the contents of the current ... Your args is actually an array, ... the same effect you need a pointer to the first element of it and then ...
    (comp.lang.c)
  • Re: Excercise 5-9 (K&R II)
    ... pointer under these circumstances advances down pointer to the next ... but it's not legal to dereference it or increment it further. ... To get to the second row of the array, ... dimensional array. ...
    (comp.lang.c)