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

Mr. Sachin Pagar is an experienced Embedded Software Engineer and the visionary founder of pythonslearning.com. With a deep passion for education and technology, he combines technical expertise with a flair for clear, impactful writing.

Leave a Reply