Why is the function working since I’m passing an array as an argument not a reference? [duplicate]

  arrays, c++, pointers, reference

Here is the code


#include <vector>
using namespace std;

void len(vector<string> a){
    cout << a.size();
void l(int a[]){

int main(){

    int b[] ={1,2};

the output I’m getting is 12

in this code in the function "l", why is the function is running? I have passed an argument of an array but the function needs the address of the array right? not the array itself. So why is the compiler not throwing any error? I’m really confused by the usage of pointers and references here .

Also instead of using void l(int a[]) if I specify void l(int a[45]) the function still works, my question why is it working? I looked at other answers here and they said it’s because the function accepts the address of the array, not the array itself which again leads to my previous question.

Source: Windows Questions C++