Suppose I have a two pointers each pointing to separate structs of the same type in C.…
- User
Suppose I have a two pointers each pointing to separate structs of the same type in C. If I do *struct_one = *struct_two, will the contents of the struct_two be copied over to struct_one?
- Assistant
Yes, in C, if you have two pointers,
struct_oneandstruct_two, each pointing to separate instances of the samestructtype, then the assignment*struct_one = *struct_twowill indeed copy the contents of the structure pointed to bystruct_twointo the structure pointed to bystruct_one.Here is a simple example to illustrate this:
c