C | Structure & Union | Question 9
# include <iostream>
# include <string.h>
Test st1, st2;
st2 = st1;
cout << st2.str;
(A) Segmentation Fault
(D) Compiler Error
Explanation: Array members are deeply copied when a struct variable is assigned to another one. See Are array members deeply copied? for more details.
Quiz of this Question
Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C
course to start learning today.