I always remember that in C language, struct values cannot be directly assigned. I asked three students that they can be used in C ++, but not in C. They need to assign values to members one by one or use the memcpy function.
I tested the following program:
[Cpp]
# Include <stdio. h>
# Include <stdlib. h>
Struct test
{
Int;
Int B;
Char ss [10];
};
Int main ()
{
Struct test t1 = {1, 2, "hello "};
Struct test t2;
T2 = t1;
Printf ("% d, % d, % s \ n", t2.a, t2. B, t2.ss );
Return 0;
}
The answer is that you can assign values directly.
I read the following on the Internet and found a discussion post with some errors or correct discussions: http://topic.csdn.net/u/20070627/15/a6b39dfa-2ab9-473e-96c3-4054800cb4c1.html
However, if a correction member is allocated dynamically and points to a memory, pay attention to it when assigning values. You cannot simply assign values directly.