I have this code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
main()
{
double b;int a[2],*c;
void myfunction();
c=(int*)(malloc(1));
b=10.;
*c=5;
a[1]=1;a[2]=2;
printf("before call %f $d $d %d\n",b,a[1],a[2],*c);
printf("before call %f $d $d %d\n",b,a[1],a[2],*c);
myfunction(b,a,c);
printf("after call %f $d $d %d\n",b,a[1],a[2],*c);
}
void myfunction(x,y,d)
double x;int y[2],*d;
{
double z;
x=2*x;
y[1]=3*y[1];
y[2]=3*y[2];
*d =*d+2;
}
when I execute it I receive this
before call 10.000000 $d $d 1
before call 10.000000 $d $d 1
after call 10.000000 $d $d 3
I expect to get 5 in first and second call and 7 in the last call, also a[i] is not shown. could you please advise me why? Thanks