'Print elements from an array [duplicate]

I am very new to C++ , and I am wandering why this code:

void display(int display[]){
    for(int i=0;i<sizeof(display)/sizeof(int);i++){
        cout<<display[i];
    }
  }

int main()
{

    int arr[]={3,1,2,5,10,20};
    display(arr);
}

prints only the first 2 elements from the array ? why not all of them? Am I missing something?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source