Pass array to a function and change its element value - C Array

C examples for Array:Array Value

Description

Pass array to a function and change its element value

Demo Code

#include <stdio.h>

void test(int val[], int max);

int main() {/*from w  w  w  .j av a  2  s  .co  m*/

    int list[5];

    for (int i = 0; i < 5; i++) 
       list[i] = i;

    test(list, 5);

    for (int i = 0; i < 5; i++) 
       printf("%d ", list[i]);

    printf("\n");
}

void test(int val[], int max) {
    for (int i = 0; i < max; i++) 
       val[i] += 25;
}

Related Tutorials