C. Why should we regard array-type function parameters as pointers to the first element of the array?

Source: Internet
Author: User

Simply put, it is two words, efficiency.

As we all know, in C function calls, parameters are passed by value, which means that a copy is generated for the real parameter during function calls, and then the function operates on this copy, that is, the function call that everyone knows will not modify the value of the real parameter, because the value is passed here.

Because function parameters need to be copied, if this function parameter is an array, this overhead may be significantly affected by performance. In general, this copy is useless, so for efficiency consideration, function parameters of the array type are considered as pointers to the first element of the array.

Of course, it can also be said that for performance considerations, it is a bit cool.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.