D
Dan Pop
In said:In alt.comp.lang.learn.c-c++ Dan Pop said:The function's prototype clearly suggests that the function is using the
pointer in write mode.
I see no particular difference between
void func(int *item1, int *item2, int *item3);
void foo()
{
int i1, i2, i3;
func(&i1, &i2, &i3);
}
and
void func(int *arr);
void foo()
{
int arr[3];
func(arr);
}
I do: one is a clean design, the other is a quick and dirty hack.
at least noct to a degree to call the seond version "safer".
Who said it's safer?
So when I debug code and see the caller side I have to assume it is
correct to make a guess on how the function works?
I was NOT talking about *debugging* code, I was talking about reading or
maintaining code. If the code is known not to behave as intended, nothing
can be assumed to be correct.
And I was, obviously, not talking about trivial cases, as the ones shown
by you.
This is not different from the original proposal.
I thought your main point was that your solution makes checking the
definition unnecessary.
Checking the definition is necessary only if you want to know what
exactly gets stored in the array. But it is a safe bet that the original
contents will not survive the call.
I am still not convinced and still maintain that your solution is not
better than the original. But maybe I simply don't
Then, feel free to use the many pointers solution, any time you need to
return multiple values from a function. Hopefully, I won't have to
maintain your code.
Dan