void f(int *a, int n)
{
int i;
for (i = 0; i < n; i++)
{
printf("%d\n", *(a+i));
}
}
The above code worked ok if in main() I called:
int a[] = {1,2,3};
int *p = a;
f(a, 3);
But if in main(), I did:
int *a =(int*) {1,2,3};
f(a, 3);
Then, the program will crash. I know this might look weird but I am studying and want to know the differences.