C-language function arguments can only be passed pointer, cannot pass array

Source: Internet
Author: User

Today is asked to write a C + + bubble algorithm program, I thought this is not extremely easy, although the recent use of JavaScript programs, very few write-C + + programs, but somehow also used for so many years C language;

The first thing to think about is how to make your code look taller, how to automatically recognize the length of the array: so the first version of the program as follows, the results are as follows

It was a surprise to see the result, why is it 2? See later I list the type of executable file, it should be known that this length is the length of the pointer, 64bit, just two bytes. Description Sortof The length of the pointer, not the length of the array.

Think about it, the function parameter can only pass the pointer, cannot pass the array directly;

So, to pass an array, you have to pass the array's first address pointer (the type of the array is consistent), and the length of the array to represent the end of the array.

C-language function arguments can only be passed pointer, cannot pass array

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.