no need to assign all the values. you need to send two pointers to the function that will copy the structure.
Code:
void copy_struct(instruction *src, instruction *dest)
{
*dest=*src;
}
See the Example:
Code:
#include<stdio.h>
typedef struct
{
int inst_addr;
}instruction;
void copy_struct(instruction *src,instruction *dest)
{
*src=*dest;
}
int main()
{
int addr = 1000;
instruction check1;
instruction check2;
check1.inst_addr = 10;
check2.inst_addr = 50;
printf("One: %d\n",check1.inst_addr);
printf("Two: %d\n",check2.inst_addr);
copy_struct(&check1,&check2);
printf("One: %d\n",check1.inst_addr);
printf("Two: %d\n",check2.inst_addr);
}
Output:
One: 10
Two: 50
One: 50
Two: 50