You can allocate the array dynamically:
#include <stdlib.h>
char *a = malloc(100*sizeof(char));
if (a == NULL)
{
// error handling
printf("The allocation of array a has failed");
exit(-1);
}
and when you want to increase its size:
tmp_a = realloc(a, 10000*sizeof(char));
if ( tmp_a == NULL ) // realloc has failed
{
// error handling
printf("The re-allocation of array a has failed");
free(a);
exit(-2);
}
else //realloc was successful
{
a = tmp_a;
}
Eventually, remember to free the allocated memory, when the array is not needed anymore:
free(a);
Basically realloc(prt, size) returns a pointer to a new memory block that has the size specified by size and deallocates the block pointed to by ptr. If it fails, the original memory block is not deallocated.
Please read here and here for further info.