Hello, I have question. In my simple code. I have some array any type. For exaple: char MyArray[55].
I passing MyArray into function FillArray. Now My function has to know max size of array. Is it possible read max size of MyArray in function FillArray?
1 2 3 4 5 6 7 8 9 10 11
void FillArray(char *array)
{
//How to read max size of array in this place?
}
int main()
{
char MyArray[55];
FillArray(MyArray);
return 0;
}
No, it is not possible, as C-style array are old and do not know their own size (+ they have otherserious problems, but it is too earl to try to understand them for you).
As LendraDwi said, pass size as second argument. However consider to not use C-arrays at all, C++ provides replacements for every potential use of C-array.