Change int type parameter value with pointer - C Pointer

C examples for Pointer:Pointer Variable

Description

Change int type parameter value with pointer

Demo Code

#include <stdio.h>

void test(int *);

int main() {/* w w w .  j  a va 2  s  . c  o  m*/

    int n = 14;

    printf("%d\n", n);   // before calling test

    test(&n);

    printf("%d\n", n);   // after return from test
}

void test(int *a) {

    *a = *a + 6;
 
    printf("%d\n", *a);  // within test
}

Related Tutorials