Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

How to change an array in a function in c

// Change the pointer of the array
void change(int **array, int length)
{
    *array = malloc(length * sizeof(int));
    if (*array == NULL)
        return;
    for (int i = 0 ; i < length ; i++)
        (*array)[i] = 1;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #change #array #function
ADD COMMENT
Topic
Name
9+6 =