Anyone kind enough to help a rookie out. What's the pointer (style?) equivalent of argv[0][1]? Consider the following code fragment executed with the following command "./test pointers"
int main(int argc, char *argv[])
{
printf("argv[0][0] = %c\n", argv[0][1]);//prints 'e'
printf("*(argv+?) = %c\n", *(argv+?));//What's the pointer equivalent of the above array?
return 0;
}
I know that *(argv+1) and argv[1] are equivalent. And yeah, I already know that arrays are const pointers.
Name:
Anonymous2011-01-24 20:22
I believe what you're looking for is *(*argv + 1) .
That's because r9k is dead, moot is banned, 4chan is offline for months, US networks collapsed, population massacred, Earth is cooling down 2 degrees Celsium every week.
If p is a pointer, then p[i] is equivalent to *(p+i). You can repeatedly apply this to multiple array subscripts: p[i][j] is equivalent to (*(p+i))[j] is equivalent to *(*(p+i)+j).