First have in mind "structure" and "array" are different things!
Array is a collection of similar data types stored in contiguous memory location. But Structure is a collection of different data types stored in contiguous memory location!
If you have a structure-
struct Struct1{
// members
}Struct_X;
function(&Struct_X); // if you change any member it will be affected
function(Struct_X); // if you change any member it will not be affected
Both are different!
Try this example-
#include<stdio.h>
struct st{
int num;
};
void print(struct st temp)
{
printf("num= %d\n",temp.num);
}
void change(struct st temp)
{
temp.num=20;
}
void changenum(struct st *temp)
{
temp->num=99;
}
int main()
{
struct st st1;
st1.num=10;
print(st1);
change(st1); // it does not modify the num
print(st1);
changenum(&st1); // but it modifies
print(st1);
}
Output-
root@sathish1:~/My Docs/Programs# ./a.out
num= 10
num= 10
num= 99