I can't understand evaluation strategy no matter how much I read the topics. Can you explain the three evaluation orders to me with an example? I am writing a code below. Can you explain call by need(lazy evaluation), call by name (normal order evaluation), call by reference using the code below. You can also explain them with your example too. All I want is to understand them, but I just can't understand.
int a[4] = {10,20,30,40};
int i = 0;
int *p;
void test(int x, int y, int z)
{
p = (int *)malloc(sizeof(int));
*p=x;
x++; y++; z++;
p = &z;
printf("%d %d %d\n",x,y,z);
x++; y++; z++;
p = &z;
printf("%d %d %d\n",x,y,z);
}
main()
{
test(i,a[0],a[i]);
printf("%d %d %d %d %d\n", a[0],a[1],a[2],a[3],*p);
}
Thanks in advance.
}