[ad_1]
You can’t modify a statically allocated variable array.
You can however use the memory allocation functions to create and modify the array:
#include <stdio.h>
// global
int size = 0;
char *array = NULL;
int main(){
scanf("%d", &size);
array = malloc(size);
if (!array)
{
... handle error.
}
scanf("%d", &size); //ask a new dimension
char *tmp = realloc(size); /reallocate array keeping old data
if (!tmp) //reallocation failed
{
free(array); //release memory
... handle error.
}
array = tmp; //reassign new memory to the array pointer
}
[ad_2]