Answers for "changing an item in an array in c"

C
3

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;
}
Posted by: Guest on July-02-2020
0

changing an item in an array in c

#include <stdio.h>
#define PI 3.142
int main(){
    int a[5] ={12, 21, 34, 23, 13};
    printf("Initial value of index 1: %d\n", a[1]);
    a[1] = 43;
    printf("Final value of index 1: %d\n", a[1]);
    
}
Posted by: Guest on April-19-2021

Code answers related to "changing an item in an array in c"

Code answers related to "C"

Browse Popular Code Answers by Language