Answers for "c change by reference"

C
0

c change by reference

void function2(int *param) {   // param must be a pointer
    printf("I've received value %d\n", *param); // print 0
    (*param)++;
}

int main(void) {
    int variable = 0;

    function2(&variable); // pass variable by reference using "&"
    printf("variable %d\n", variable); // print 1
    
    
    return 0;
}
Posted by: Guest on October-16-2021

Code answers related to "c change by reference"

Code answers related to "C"

Browse Popular Code Answers by Language