Follow const link in C

Is C support supported by referencing const, like C ++? If not, are there other ways to improve the transmission efficiency by value? I don’t think it makes sense to pass references to a function just because it is more efficient.

+4
source share
1 answer

C does not support links or passes by reference. Instead, you should use pointers and pass to the address. Passing by value is effective for primitive types, but makes a shallow copy for structures.

In C ++, it makes a lot of sense to pass objects by reference to increase efficiency. It can save a ton of copying and calling constructors / destructors when defining copy constructors. For large data objects (for example std::list), it is impractical to pass by value, since the list will be copied during the transfer. Here you must follow the link.

+8
source

All Articles