#include <stdio.h>
#include <stdlib.h>

int main(void) 
{
	int i, m, max = 100;
	
    //creating a large enough array to store user inputs
    int *array = malloc(sizeof(int) * max); 
    
    //check if memory was allocated or not    
    if(array == NULL)
    {
        printf("memory allocation problem!");
        exit(1);
    }

    //integer to make note of size of array or you can use the sizeof() function instead
    int size_of_array = 0;

    for (i = 0; i < max; i++)
    {
        printf("Fill the table with integers: ");

        if(scanf("%d", &m) != 1) //check for `scanf`
        {
        	char consume;
            printf("wrong input, try again\n");
            scanf("%c", &consume);
            i--;
            continue;
        }

        if (m > 0) //if positive number, accept
        {
            array[i] = m;
            printf("a[%d] = %d\n",i,m);
            size_of_array++;
        }
      
        else       //else break out of scanning
        {
            break;
        }
    }

    //do the program.....

    //don't for get to free the memory at the end
    free(array);
}
