Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, a struct can be safely returned in C or C++. When a struct is returned from a function, it is usually passed by value unless it is explicitly passed by reference. This means that a copy of the struct is created and returned to the calling function. However, if the struct is large or contains pointers, it may be more efficient to pass a pointer to the struct instead of passing it by value. In either case, the struct can be safely returned.