Your two examples are the same, passing by reference.
I have doubt I don't see where I am passing structure by referenceWhen you reference an array by its name alone, the value is a pointer to the array. You do this in example 9.
C:
#include <stdio.h>
struct student
{
int x;
int y;
};
// function prototype
void display(struct student point);
int main()
{
struct student mypoint;
mypoint.x = 1;
mypoint.y = 2;
display(mypoint); // passing struct as an argument
return 0;
}
void display(struct student point) // updated name point instead of mypoint
{
printf("\n Displaying information\n");
printf("\n x: %d", point.x);
printf("\n y: %d", point.y);
}
There is example for Passing Structure by Value
Last edited: