To make the array resizeable, you need to create it using malloc()...
Code:
#include<stdio.h>
#define ASIZE 100
int main(void)
{
int *arry = malloc(ASIZE * sizeof(int));
int count=0;
do
{
printf("Input value:");
scanf("%d", &arry[count]);
count++;
}
while(arry[count]!=0);
return 0;
}
You can treat this just like any other array, using indexing or pointers... it's just that it's created on the program's memory Heap rather than on it's Stack.
Now you have some choices...
If you are certain you will not exceed ASIZE in the example above, you're all done...
If the operator will know the size you can ask...
Code:
#include<stdio.h>
int main(void)
{
int *arry;
int size;
int count=0;
printf("How many entries? : ");
scanf("%d", &size);
arry = malloc(size * sizeof(int));
do
{
printf("Input value:");
scanf("%d", &arry[count]);
count++;
}
while(arry[count]!=0);
return 0;
}
or if the array is of a totally unknown size at runtime...
Code:
#include<stdio.h>
#define ASIZE 10
int main(void)
{
int *arry = malloc(ASIZE * sizeof(int));
int count = 0;
int size = ASIZE;
do
{
printf("Input value:");
scanf("%d", &arry[count]);
count++;
// resize the array
if (count >= size)
{
size += ASIZE;
arry = realloc(arry, size * sizeof(int));
}
}
while(arry[count]!=0);
return 0;
}
... which will automatically increase the size of the array in blocks of ASIZE (10 in the example) as the operator enters new data.
Now... don't be just copy pasting the examples, you won't learn anything that way (and they are untested)... Get into your C language documentation (compiler's help files) and read up on malloc() and realloc() so you understand what is actually going on.