M
mdh
Hi all,
I have gone through the FAQ and done searches in the Comp.Lang and if
I have missed it please let me have the ref.
(Question generated in part by p119).
Given
char a[10];
char *b[8];
int foo(char *s, char *[]);
Now, if in main, I do this:
int i;
i=foo(a, b);
it is my understanding that what is passed to "foo", as parameters,
is
1) a pointer to [ index 0] of type "pointer-to-char" (for a)
2) a pointer to index 0 of type "pointer to pointer to char" ( for
b)
My question is this. If this is indeed correct, then from the
standpoint of the function foo, what is the difference in the two
pointers? From the programmer's standpoint, the difference is more
obvious. In the first case, *ptr yields a character, and in the second
place, *ptr yields a pointer to character. I am not sure if I am
framing this correctly.
Perhaps, I can ask this another way. Not knowing anything about how
the pointers were generated, if you were to be handed each pointer at
the level of the function, could you tell the difference. If you can
then my question is somewhat answered, if not then how does the
compiler know what to do with each pointer.
If the question is somewhat confusing, it is because I am not quite
sure what it is that I am missing.
Or...I am making this far too complicated...which is more than likely.
Thanks in advance.
I have gone through the FAQ and done searches in the Comp.Lang and if
I have missed it please let me have the ref.
(Question generated in part by p119).
Given
char a[10];
char *b[8];
int foo(char *s, char *[]);
Now, if in main, I do this:
int i;
i=foo(a, b);
it is my understanding that what is passed to "foo", as parameters,
is
1) a pointer to [ index 0] of type "pointer-to-char" (for a)
2) a pointer to index 0 of type "pointer to pointer to char" ( for
b)
My question is this. If this is indeed correct, then from the
standpoint of the function foo, what is the difference in the two
pointers? From the programmer's standpoint, the difference is more
obvious. In the first case, *ptr yields a character, and in the second
place, *ptr yields a pointer to character. I am not sure if I am
framing this correctly.
Perhaps, I can ask this another way. Not knowing anything about how
the pointers were generated, if you were to be handed each pointer at
the level of the function, could you tell the difference. If you can
then my question is somewhat answered, if not then how does the
compiler know what to do with each pointer.
If the question is somewhat confusing, it is because I am not quite
sure what it is that I am missing.
Or...I am making this far too complicated...which is more than likely.
Thanks in advance.