Basics of call by reference in embedded c

Spread the love

There are two methods to he data into the function in embedded c

  1. Call by value
  2. Call by reference
 call by reference in embedded c
call by reference in embedded c

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
Basics of call by reference in embedded c
Basics of call by reference in embedded c

Summary:

In this article we saw call by value with example.

sachin Pagar

I am Mr. Sachin pagar Embedded software engineer, the founder of Sach Educational Support(Pythonslearning), a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Reply