I have two functions, I need one to add a value to a variable and the other to print it, but the output is incorrect to what I expect.
What I do is define a function, passing a sum pointer as a parameter, in another function I create the variable that I will pass as a parameter and I invoke the new function passing that variable as an address, but when printing it it fails.
    #include <stdio.h>
    void test() {
        int sum;
        test2(&sum);
        printf("%d",sum);
    }
    void test2(int *sumador) {
        int i;
        for(i = 0; i < 10; i++) {
            sumador += i;
        }
    }
    int main() {
        test();
    }
 
     
    