So, I think the answer is that there is no easy way to do this with C style arrays in general. Which is usually why you see the size of the array passed into a function in cases like this. i.e. you would have:

void processArray(int* a, size_t size)
{
....
}

a better solution is not to use C style arrays at all and use something like the STL vector class instead.

In that case, I would say that is a pointer (int *) instead of an array (int []) though they are almost the same. Besides passing the size as jasonclarke showed, you may also use a special number that is not being used as the terminator of the array.

0

FreateAuthor Commented: 1999-12-02

Thank you all.
in fact I'm a Delphi programmer before,
and this is easy in delphi.

when i move to c, I found STL is very useful,but i have not even be familar with some basic C/C++ problems.