Ad
  • Custom User Avatar

    im guessing people just blindly click the upvotes just because its at the top

  • Custom User Avatar

    Use spoiler flag next time please.

  • Custom User Avatar
    • count-- evaluates count and then decrements it. In C 0 has a false boolean value, so the loop will stop when count is 0
    • incrementing/decrementing a pointer to type T will add/subtract sizeof T to the pointer address, so values++ will jump to the next element of values
    • *values++ will first evaluate *values and then increment values. This is being overly clever with operator priority. *(values++) would have been clearer
    • last but not least: this code is wrong. It contains undefined behavior because the C specification does not guarantee the order of operations in (*values) * (*(values++)). Just because it is written left-to-right does not mean it will be evaluated left-to-right. This code just happens to work.

    Be careful with top voted solutions on Codewars, they are usually garbage