I can not find an error in the code, the function sum , with a variable number of parameters, the first argument takes the number of arguments, then the arguments themselves. In the cycle I refer to the wrong addresses. Help me find a bug.
#include <stdio.h> void sum(int k, ...) { int *p = &k; int sum = 0; for (int i = 0; i < k; ++i){ ++p; sum += *p; } printf("%d", sum); } int main() { sum(3, 1, 2, 3); return 0; }