Stopping an Array before reaching size limit.
I'm trying to write a program that will allow the user to input up to 1000 numbers in a one dimensional array.
Code:
/*Function that loads the array*
/void loadArray(int a[]){
int i;
for (i = 0; i < ASIZE; i++) {
printf("Enter up to 1000 numbers: ");
scanf("%i", &a[i]);
}
return;
}
How would I be able to have the user stop the array when they've entered the amount of numbers that they needed to enter. Right now it continues until 1000 numbers have been entered.
Thank you so much!
I found the answer online!
Code:
printf("Enter the number of elements in array\n");
scanf("%d",&size);
printf("Enter %d integers\n", size);
for ( c = 0 ; c < size ; c++ )
scanf("%d", &array[c]);