我试图用数组
lebron
中的元素填充数组curry
,然后编写一个函数来打印填充的数组。但是输出并不像预期的那样。
我的代码:
#include <iostream>
using namespace std;
void printArray(int arr[]){
int arrayLength = sizeof(arr) / sizeof(int);
cout << "[";
for(int i=0; i<arrayLength; i++){
cout << arr[i] << " ";
}
cout << "]";
}
int main(){
int curry[6] = {0, 1, 2, 3, 4, 5};
int lebron[6];
for(int i=0; i<6; i++){
lebron[i] = curry[i];
}
printArray(lebron);
} //end main
我期望的输出是:
[0 1 2 3 4 5]
实际输出:
[0 1 ]