Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - The following is a C language program that calculates the sum of each element in an array A. When the parameter len is 0, the return value should be 0, but when it is executed on a machine,
The following is a C language program that calculates the sum of each element in an array A. When the parameter len is 0, the return value should be 0, but when it is executed on a machine,
Len in the function is defined as an unsigned integer. When you pass a parameter of 0, what is len- 1? -1, but due to unsigned shaping, the calculation result of complement is binary 32-bit all 1, that is, len- 1==4294967295, so the for circular access array is out of bounds, and there are exceptions.