This is (one of) the difference between arrays and pointers. Taking the size of the array results in its size in bytes, while the size of the pointer gives the size of the pointers in this system. However , whenever you pass an array to a function, it splits into a pointer whose size is always the same no matter what type of pointer it is (4 on a 32-bit machine).
So it is technically impossible to pass an array to a function, because whenever you try, it becomes a pointer.
You also need to pass the size of the array to the function, or, if you want, even better, use std::vector or std::array or std::string if you use the array as a C-style String.
source share