![]() |
Array copying problem
Hi I am trying to copy one struct to another, but I am making some minor mistake that it is not getting copied. Can someone help me fix it?
Code:
|
Re: Array copying problem
You need to send two pointers to the function that will copy the structure.
Code:
void copy_struct(instruction *src, instruction *dest)see the Link http://cboard.cprogramming.com/c-pro...n-problem.html |
Re: Array copying problem
You can not straight away copy the structure ,you need to pass the address of the structure to the function then using that address you can copy the contents.
|
Re: Array copying problem
@ungalnanban
Thanks for ur reply.. But when i call the function in main, I get this error. |
Re: Array copying problem
This is the error message:
error: incompatible type for argument 1 of ‘copy_struct’ note: expected ‘struct instruction *’ but argument is of type ‘instruction’ error: incompatible type for argument 2 of ‘copy_struct’ note: expected ‘struct instruction *’ but argument is of type ‘instruction’ Am I making some mistake in calling the fuction? |
Re: Array copying problem
Code:
typedef struct |
Re: Array copying problem
The above code is similar to arun10427 code , but I changed the function call as a
call by reference. |
Re: Array copying problem
want to copy the whole struct
try this *dest =*src ; |
Re: Array copying problem
See the following Example:
Code:
#include<stdio.h>One: 10 Two: 50 One: 50 Two: 50 |
| All times are GMT +5.5. The time now is 01:47. |