Can someone explain to me why this code works:
#include <stdio.h>
void set_array(int array[3]);
int main()
{
int a[3] = {1, 2, 3};
set_array(a);
for (int i = 0; i < 4; i++)
{
printf("%d\n", a[i]);
}
}
void set_array(int array[3])
{
array[3] = 4;
}
How is it possible that I can add an element to an array through a function call? Can someone explain to me what's happening behind the curtains here?
Thanks in advance.