Professional Documents
Culture Documents
StructAsParameter 19
StructAsParameter 19
Structure as Parameter
call by value
- Example
int main()
{
struct rectangle r = {10,5};
printf("% d", area(r));
}
• If you are making changes to formal parameter it will not e ect the
actual parameter
fi
ff
call by reference
- Example
int main()
{
struct rectangle r = {10,5};
printf("% d", area(r));
}
• Here the new object is not created but the same object
is called r1 also
ff
call by address
- Example
{
p -> length = l;
}
int main()
{
struct rectangle r = {10,5};
ChangeLength(&r, 20);
}