There are two methods to he data into the function in embedded c
- Call by value
- Call by reference
Call by reference in embedded c
In call by reference , the addresses value of the variable is passed into the function call
the value of the actual parameters can be changing the formal parameters since the address of the actual parameters is passed
#include<stdio.h>
void change(int*num)
{
printf("%d\n",*num);
*num+=100;
printf("%d\n",*num);
}
int main()
{
int x=150;
printf("%d\n",x);
change(&x);
printf("%d\n",x);
return 0;
}
/tmp/X1GjUoqPIW.o
150
150
250
250
Summary:
In this article we saw call by value with example.