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