When print_array is called, the size of the int array[] parameter (count) isn't what was expected. It seems sizeof is not returning the size of the entire array which would be 5*sizeof(int) = 20.
namespace Util { void print_array(int array[]) { size_t count = (sizeof array)/(sizeof array[0]); cout << count; // int count = sizeof(array)/sizeof(array[0]); // for (int i = 0; i <= count; i++) cout << array[i]; } } int array_test[5]={2,1,5,4,3}; Util::print_array(array_test);
std::arrayby default, so that "C array" would make sense, but that isn't the case yet.