I wrote a piece of c code :
struct Res {
int a;
float b;
double c;
};
struct Res ModRes(struct Res rrr)
{
rrr.a=222;
return rrr;
}
int main()
{
struct Res r[10]={1,2,3};
ModRes(r[0]);
return 0;
}
why r[0] is not 222 after ModRes ?
In C, arguments are passed by value. You could make the function accept a
struct Res *rather than astruct Res: